diff --git a/.cache/v/cache/lastfailed b/.cache/v/cache/lastfailed new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.cache/v/cache/lastfailed @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/.cache/v/pep8/mtimes b/.cache/v/pep8/mtimes new file mode 100644 index 0000000..70f43ae --- /dev/null +++ b/.cache/v/pep8/mtimes @@ -0,0 +1,6 @@ +{ + "/Users/chaim/Dropbox/github/flask-modus/test_flask_modus.py": [ + 1503164934.0, + [] + ] +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index b3d08c9..9defa83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,19 @@ language: python python: - "2.7" + - "3.6" env: - FLASK_VERSION=0.8 - FLASK_VERSION=0.9 - FLASK_VERSION=0.10 + - FLASK_VERSION=0.12 install: - "pip install -r requirements.txt" - "pip install -I Flask==$FLASK_VERSION" -script: "invoke travisci" \ No newline at end of file +script: "invoke travisci" +matrix: + exclude: + - python: "3.6" + env: FLASK_VERSION=0.8 + - python: "3.6" + env: FLASK_VERSION=0.9 \ No newline at end of file diff --git a/README.rst b/README.rst index e511d16..ae09147 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,7 @@ Flask-Modus ===================== +This is the same flask_modus as done by Rhys Elsmore with a slight change by Chaim Finkelman to make it work with both python 3.6 and 2.7 . + .. image:: https://secure.travis-ci.org/rhyselsmore/flask-modus.png?branch=master diff --git a/flask_modus.py b/flask_modus.py index 57a3918..ac9f042 100644 --- a/flask_modus.py +++ b/flask_modus.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from werkzeug import url_decode - +from sys import version_info class Middleware(object): """ WSGI Method Overriding Middleware """ @@ -26,7 +26,8 @@ def __call__(self, environ, response): def set_method(method): if method in self.allowed_methods: - method = method.encode('ascii', 'replace') + if version_info[0] < 3: + method = method.encode('ascii', 'replace') environ['REQUEST_METHOD'] = method if method in self.bodyless_methods: environ['CONTENT_LENGTH'] = '0' diff --git a/tasks.py b/tasks.py index 70a964d..421990a 100644 --- a/tasks.py +++ b/tasks.py @@ -2,10 +2,10 @@ @task -def test(): +def test(ctx): run('py.test --pep8 --cov=flask_modus test_flask_modus.py', pty=True) @task -def travisci(): +def travisci(ctx): run('py.test --pep8 test_flask_modus.py') diff --git a/test_flask_modus.py b/test_flask_modus.py index 52aaa46..aa284ba 100644 --- a/test_flask_modus.py +++ b/test_flask_modus.py @@ -27,15 +27,15 @@ def put(): def test_get(self): """ Test get """ - assert "get" in self.client.get('/').data + assert "get" in self.client.get('/').data.decode('ascii') def test_query_string(self): """ Test put """ rv = self.client.put('/') - assert "put" in rv.data + assert "put" in rv.data.decode('ascii') rv = self.client.post('/?_method=put') - assert "put" in rv.data + assert "put" in rv.data.decode('ascii') with self.app.test_client() as c: c.post('/?_method=put')