Skip to content

Commit

Permalink
Merge pull request #488 from csojinb/jython_support
Browse files Browse the repository at this point in the history
feat(general): support Jython 2.7rc2
  • Loading branch information
jmvrbanac committed Apr 15, 2015
2 parents 73d9f41 + d2c2ce9 commit 67c22a6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*.c
*.so

# Jython
*$py.class

# Packages
*.egg
*.egg-info
Expand Down
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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...

Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/test_middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ def test_log_get_request(self):
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")


Expand Down Expand Up @@ -151,9 +151,9 @@ def test_generate_trans_id_and_time_with_request(self):
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):
Expand Down
12 changes: 5 additions & 7 deletions tests/test_request_body.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import io
import multiprocessing
import threading
from wsgiref import simple_server

import requests
Expand Down Expand Up @@ -87,12 +87,12 @@ def on_put(self, req, resp):
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)
Expand All @@ -101,8 +101,6 @@ def on_put(self, req, resp):
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')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# -*- coding: utf-8-*-
# -*- coding: utf-8 -*-

from datetime import datetime
import functools
Expand Down
6 changes: 6 additions & 0 deletions travis_scripts/install.sh
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions travis_scripts/install_jython2.7.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions travis_scripts/run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if [ "$JYTHON" = "true" ]; then
$HOME/jython/bin/nosetests
else
tox -e $TOX_ENV
fi

0 comments on commit 67c22a6

Please sign in to comment.