diff --git a/.gitignore b/.gitignore index e0eb00b8..5d85a852 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ nosetests.xml *.out _build + +.hypothesis diff --git a/.travis.yml b/.travis.yml index 36746df9..ee7e3185 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/tests/test_hypothesis.py b/extra/test_hypothesis.py similarity index 75% rename from tests/test_hypothesis.py rename to extra/test_hypothesis.py index f51e7461..7606e308 100644 --- a/tests/test_hypothesis.py +++ b/extra/test_hypothesis.py @@ -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.