Merge pull request #488 from csojinb/jython_support

feat(general): support Jython 2.7rc2
This commit is contained in:
John Vrbanac
2015-04-15 12:57:31 -05:00
9 changed files with 42 additions and 16 deletions

3
.gitignore vendored
View File

@@ -4,6 +4,9 @@
*.c *.c
*.so *.so
# Jython
*$py.class
# Packages # Packages
*.egg *.egg
*.egg-info *.egg-info

View File

@@ -1,6 +1,6 @@
language: python language: python
sudo: false sudo: false
install: pip install tox coveralls --use-mirrors install: travis_scripts/install.sh
cache: cache:
directories: directories:
- $HOME/.cache/pip - $HOME/.cache/pip
@@ -18,8 +18,9 @@ env:
- TOX_ENV=pylint - TOX_ENV=pylint
- TOX_ENV=py27_smoke - TOX_ENV=py27_smoke
- TOX_ENV=py27_smoke_cython - TOX_ENV=py27_smoke_cython
- JYTHON=true
script: tox -e $TOX_ENV script: travis_scripts/run_tests.sh
after_success: coveralls after_success: coveralls
notifications: notifications:
irc: irc:

View File

@@ -2,7 +2,7 @@
Kurt Griffiths (kgriffs) is the creator and current maintainer of the Falcon framework. Pull requests are always welcome. 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): 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 * **perf**: A code change that improves performance
* **test**: Adding missing tests * **test**: Adding missing tests
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation * **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation
##### Scope ##### Scope
The scope could be anything specifying place of the commit change. For example: `$location`, `$browser`, `$compile`, `$rootScope`, `ngHref`, `ngClick`, `ngView`, etc... 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 ##### Footer
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**. 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 [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 [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 [goog-style]: http://google-styleguide.googlecode.com/svn/trunk/pyguide.html#Comments

View File

@@ -112,9 +112,9 @@ class TestRequestTimeMiddleware(TestMiddleware):
self.assertIn("start_time", context) self.assertIn("start_time", context)
self.assertIn("mid_time", context) self.assertIn("mid_time", context)
self.assertIn("end_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") "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") "process_response not executed after request")
@@ -151,9 +151,9 @@ class TestSeveralMiddlewares(TestMiddleware):
self.assertIn("start_time", context) self.assertIn("start_time", context)
self.assertIn("mid_time", context) self.assertIn("mid_time", context)
self.assertIn("end_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") "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") "process_response not executed after request")
def test_middleware_execution_order(self): def test_middleware_execution_order(self):

View File

@@ -1,5 +1,5 @@
import io import io
import multiprocessing import threading
from wsgiref import simple_server from wsgiref import simple_server
import requests import requests
@@ -87,12 +87,12 @@ class TestRequestBody(testing.TestBase):
httpd = simple_server.make_server('127.0.0.1', 8989, api) httpd = simple_server.make_server('127.0.0.1', 8989, api)
httpd.serve_forever() httpd.serve_forever()
process = multiprocessing.Process(target=server) thread = threading.Thread(target=server)
process.daemon = True thread.daemon = True
process.start() thread.start()
# Let it boot # Let it boot
process.join(1) thread.join(1)
url = 'http://127.0.0.1:8989/echo' url = 'http://127.0.0.1:8989/echo'
resp = requests.post(url, data=expected_body) resp = requests.post(url, data=expected_body)
@@ -101,8 +101,6 @@ class TestRequestBody(testing.TestBase):
resp = requests.put(url, data=expected_body) resp = requests.put(url, data=expected_body)
self.assertEqual(resp.text, expected_body) self.assertEqual(resp.text, expected_body)
process.terminate()
def test_body_stream_wrapper(self): def test_body_stream_wrapper(self):
data = testing.rand_string(SIZE_1_KB / 2, SIZE_1_KB) data = testing.rand_string(SIZE_1_KB / 2, SIZE_1_KB)
expected_body = data.encode('utf-8') expected_body = data.encode('utf-8')

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8-*- # -*- coding: utf-8 -*-
from datetime import datetime from datetime import datetime
import functools import functools

6
travis_scripts/install.sh Executable file
View File

@@ -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

View File

@@ -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

5
travis_scripts/run_tests.sh Executable file
View File

@@ -0,0 +1,5 @@
if [ "$JYTHON" = "true" ]; then
$HOME/jython/bin/nosetests
else
tox -e $TOX_ENV
fi