Skip to content

Commit 50b953c

Browse files
committed
Move hypothesis tests other to new extra/ dir
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
1 parent 2aa3ca2 commit 50b953c

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,5 @@ nosetests.xml
3535

3636
*.out
3737
_build
38+
39+
.hypothesis

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ install:
1616
- pip install dist/*.whl
1717
script:
1818
- cd tests/ && nosetests --with-coverage --cover-package jmespath .
19-
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then JP_MAX_EXAMPLES=10000 nosetests test_hypothesis.py; fi
19+
- if [[ $TRAVIS_PYTHON_VERSION != '2.6' ]]; then JP_MAX_EXAMPLES=10000 nosetests ../extra/test_hypothesis.py; fi
2020
after_success:
2121
- codecov

tests/test_hypothesis.py renamed to extra/test_hypothesis.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,24 @@
1414
from jmespath import exceptions
1515

1616

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

3121

22+
RANDOM_JSON = st.recursive(
23+
st.floats() | st.booleans() | st.text() | st.none(),
24+
lambda children: st.lists(children) | st.dictionaries(st.text(), children)
25+
)
26+
27+
28+
MAX_EXAMPLES = int(os.environ.get('JP_MAX_EXAMPLES', 1000))
3229
BASE_SETTINGS = {
3330
'max_examples': MAX_EXAMPLES,
3431
'suppress_health_check': [HealthCheck.too_slow],
3532
}
3633

3734

38-
def setup_module():
39-
if sys.version_info[:2] == (2, 6):
40-
raise SkipTest("Hypothesis test not supported on py26")
41-
42-
4335
# For all of these tests they verify these proprties:
4436
# either the operation succeeds or it raises a JMESPathError.
4537
# If any other exception is raised then we error out.

0 commit comments

Comments
 (0)