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
*.so
# Jython
*$py.class
# Packages
*.egg
*.egg-info

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8-*-
# -*- coding: utf-8 -*-
from datetime import datetime
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