diff --git a/.gitignore b/.gitignore index 9d28c79..45cce38 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,9 @@ *.c *.so +# Jython +*$py.class + # Packages *.egg *.egg-info diff --git a/.travis.yml b/.travis.yml index 1707172..28fce24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python sudo: false -install: pip install tox coveralls --use-mirrors +install: travis_scripts/install.sh cache: directories: - $HOME/.cache/pip @@ -18,8 +18,9 @@ env: - TOX_ENV=pylint - TOX_ENV=py27_smoke - TOX_ENV=py27_smoke_cython + - JYTHON=true -script: tox -e $TOX_ENV +script: travis_scripts/run_tests.sh after_success: coveralls notifications: irc: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2aa67b3..74d52ac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ Kurt Griffiths (kgriffs) is the creator and current maintainer of the Falcon framework. Pull requests are always welcome. -Before submitting a pull request, please ensure you have added or updated tests as appropriate, and that all existing tests still pass with your changes on both Python 2 and Python 3. Please also ensure that your coding style follows PEP 8 and doesn't cause pyflakes to complain. +Before submitting a pull request, please ensure you have added or updated tests as appropriate, and that all existing tests still pass with your changes on both Python 2 and Python 3. Please also ensure that your coding style follows PEP 8 and doesn't cause pyflakes to complain. You can check all this by running the following from within the falcon project directory (requires Python 2.7 and Python 3.3 to be installed on your system): @@ -63,7 +63,7 @@ Must be one of the following: * **perf**: A code change that improves performance * **test**: Adding missing tests * **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation - + ##### Scope The scope could be anything specifying place of the commit change. For example: `$location`, `$browser`, `$compile`, `$rootScope`, `ngHref`, `ngClick`, `ngView`, etc... @@ -80,6 +80,16 @@ Just as in the **subject**, use the imperative, present tense: "change" not "cha ##### Footer The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**. +### Running tests against Jython +In addition to the tests run with tox against cpython, cython, and pypy versions, Travis runs tests against jython 2.7 outside of tox. If you need to run these tests locally, do the following: +* Install JDK 7 or better +* run `travis_scripts/install_jython2.7.sh` -- this will install jython at `~/jython` +* Install testing requirements `~/jython/bin/pip install -r tools/test-requires` + * May need to set `export JYTHON_HOME=~/jython` first +* Run tests `~/jython/bin/nosetests` + +Note: coverage does not support Jython, so the coverage tests will fail. + [ajs]: https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit [docstrings]: http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_google.html#example-google-style-python-docstrings [goog-style]: http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments diff --git a/tests/test_middlewares.py b/tests/test_middlewares.py index 9c37e34..226e57f 100644 --- a/tests/test_middlewares.py +++ b/tests/test_middlewares.py @@ -112,9 +112,9 @@ class TestRequestTimeMiddleware(TestMiddleware): self.assertIn("start_time", context) self.assertIn("mid_time", context) self.assertIn("end_time", context) - self.assertTrue(context['mid_time'] > context['start_time'], + self.assertTrue(context['mid_time'] >= context['start_time'], "process_resource not executed after request") - self.assertTrue(context['end_time'] > context['start_time'], + self.assertTrue(context['end_time'] >= context['start_time'], "process_response not executed after request") @@ -151,9 +151,9 @@ class TestSeveralMiddlewares(TestMiddleware): self.assertIn("start_time", context) self.assertIn("mid_time", context) self.assertIn("end_time", context) - self.assertTrue(context['mid_time'] > context['start_time'], + self.assertTrue(context['mid_time'] >= context['start_time'], "process_resource not executed after request") - self.assertTrue(context['end_time'] > context['start_time'], + self.assertTrue(context['end_time'] >= context['start_time'], "process_response not executed after request") def test_middleware_execution_order(self): diff --git a/tests/test_request_body.py b/tests/test_request_body.py index c8387f5..8b47039 100644 --- a/tests/test_request_body.py +++ b/tests/test_request_body.py @@ -1,5 +1,5 @@ import io -import multiprocessing +import threading from wsgiref import simple_server import requests @@ -87,12 +87,12 @@ class TestRequestBody(testing.TestBase): httpd = simple_server.make_server('127.0.0.1', 8989, api) httpd.serve_forever() - process = multiprocessing.Process(target=server) - process.daemon = True - process.start() + thread = threading.Thread(target=server) + thread.daemon = True + thread.start() # Let it boot - process.join(1) + thread.join(1) url = 'http://127.0.0.1:8989/echo' resp = requests.post(url, data=expected_body) @@ -101,8 +101,6 @@ class TestRequestBody(testing.TestBase): resp = requests.put(url, data=expected_body) self.assertEqual(resp.text, expected_body) - process.terminate() - def test_body_stream_wrapper(self): data = testing.rand_string(SIZE_1_KB / 2, SIZE_1_KB) expected_body = data.encode('utf-8') diff --git a/tests/test_utils.py b/tests/test_utils.py index b6dc260..b5a0d35 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8-*- +# -*- coding: utf-8 -*- from datetime import datetime import functools diff --git a/travis_scripts/install.sh b/travis_scripts/install.sh new file mode 100755 index 0000000..64230c0 --- /dev/null +++ b/travis_scripts/install.sh @@ -0,0 +1,6 @@ +if [ "$JYTHON" = "true" ]; then + travis_scripts/install_jython2.7.sh + $HOME/jython/bin/pip install -r tools/test-requires +else + pip install tox coveralls --use-mirrors +fi diff --git a/travis_scripts/install_jython2.7.sh b/travis_scripts/install_jython2.7.sh new file mode 100755 index 0000000..0ab6d56 --- /dev/null +++ b/travis_scripts/install_jython2.7.sh @@ -0,0 +1,3 @@ +JYTHON_URL="http://search.maven.org/remotecontent?filepath=org/python/jython-installer/2.7-rc2/jython-installer-2.7-rc2.jar" +wget $JYTHON_URL -O jython_installer.jar +java -jar jython_installer.jar -s -d $HOME/jython diff --git a/travis_scripts/run_tests.sh b/travis_scripts/run_tests.sh new file mode 100755 index 0000000..5d5bc96 --- /dev/null +++ b/travis_scripts/run_tests.sh @@ -0,0 +1,5 @@ +if [ "$JYTHON" = "true" ]; then + $HOME/jython/bin/nosetests +else + tox -e $TOX_ENV +fi