Skip to content

Commit

Permalink
Move hypothesis tests other to new extra/ dir
Browse files Browse the repository at this point in the history
Makes it easier than trying to deal with 2.6 incompatibility
in the main test suite.  Now we can just check in the .travis.yml
if we're on 2.6 and skip running these tests
  • Loading branch information
jamesls committed Mar 21, 2016
1 parent 2aa3ca2 commit 50b953c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ nosetests.xml

*.out
_build

.hypothesis
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ install:
- pip install dist/*.whl
script:
- cd tests/ && nosetests --with-coverage --cover-package jmespath .
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then JP_MAX_EXAMPLES=10000 nosetests test_hypothesis.py; fi
- if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then JP_MAX_EXAMPLES=10000 nosetests ../extra/test_hypothesis.py; fi
after_success:
- codecov
28 changes: 10 additions & 18 deletions tests/test_hypothesis.py → extra/test_hypothesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@
from jmespath import exceptions


MAX_EXAMPLES = int(os.environ.get('JP_MAX_EXAMPLES', 100))
if sys.version_info[:2] != (2, 6):
RANDOM_JSON = st.recursive(
st.floats() | st.booleans() | st.text() | st.none(),
lambda children: st.lists(children) | st.dictionaries(st.text(), children)
)
else:
# hypothesis doesn't work on py26 and the prevous definition of
# RANDOM_JSON would throw an error. We set RANDOM_JSON to some
# arbitrary value that we know will work. This isn't going to get
# called anyways.
# XXX: Is there a better way to do this?
RANDOM_JSON = st.none()
if sys.version_info[:2] == (2, 6):
raise RuntimeError("Hypothesis tests are not supported on python2.6. "
"Use python2.7, or python3.3 and greater.")


RANDOM_JSON = st.recursive(
st.floats() | st.booleans() | st.text() | st.none(),
lambda children: st.lists(children) | st.dictionaries(st.text(), children)
)


MAX_EXAMPLES = int(os.environ.get('JP_MAX_EXAMPLES', 1000))
BASE_SETTINGS = {
'max_examples': MAX_EXAMPLES,
'suppress_health_check': [HealthCheck.too_slow],
}


def setup_module():
if sys.version_info[:2] == (2, 6):
raise SkipTest("Hypothesis test not supported on py26")


# For all of these tests they verify these proprties:
# either the operation succeeds or it raises a JMESPathError.
# If any other exception is raised then we error out.
Expand Down

0 comments on commit 50b953c

Please sign in to comment.