Skip to content

Commit

Permalink
Merge pull request #190 from DavidCEllis/fix_tests
Browse files Browse the repository at this point in the history
Fix build - Hypothesis and Pytest issues
  • Loading branch information
josegonzalez committed Dec 18, 2017
2 parents 1ca4f45 + 5717b92 commit 61574c9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -18,7 +18,7 @@ matrix:
- python: "pypy3.5-5.8.0"
env: TEST_SUITE="py.test test_fuzzywuzzy.py test_fuzzywuzzy_pytest.py"
install:
- pip install pytest pycodestyle
- pip install pytest==3.2.5 pycodestyle
- if [ $TRAVIS_PYTHON_VERSION != 2.6 -a $TRAVIS_PYTHON_VERSION != "pypy3" ]; then pip install hypothesis; fi;
- if [ $TRAVIS_PYTHON_VERSION = 3.3 ]; then pip install enum34; fi;
script:
Expand Down
23 changes: 17 additions & 6 deletions test_fuzzywuzzy_hypothesis.py
@@ -1,5 +1,6 @@
from itertools import product
from functools import partial
from string import ascii_letters, digits, punctuation

from hypothesis import given, assume, settings
import hypothesis.strategies as st
Expand All @@ -8,6 +9,9 @@
from fuzzywuzzy import fuzz, process, utils


HYPOTHESIS_ALPHABET = ascii_letters + digits + punctuation


def scorers_processors():
"""
Generate a list of (scorer, processor) pairs for testing
Expand Down Expand Up @@ -58,7 +62,7 @@ def full_scorers_processors():
@pytest.mark.parametrize('scorer,processor',
scorers_processors())
@given(data=st.data())
@settings(max_examples=100)
@settings(max_examples=20, deadline=5000)
def test_identical_strings_extracted(scorer, processor, data):
"""
Test that identical strings will always return a perfect match.
Expand All @@ -70,8 +74,12 @@ def test_identical_strings_extracted(scorer, processor, data):
"""
# Draw a list of random strings
strings = data.draw(
st.lists(st.text(min_size=10, max_size=100),
min_size=1, max_size=50))
st.lists(
st.text(min_size=10, max_size=100, alphabet=HYPOTHESIS_ALPHABET),
min_size=1,
max_size=10
)
)
# Draw a random integer for the index in that list
choiceidx = data.draw(st.integers(min_value=0, max_value=(len(strings) - 1)))

Expand Down Expand Up @@ -99,7 +107,7 @@ def test_identical_strings_extracted(scorer, processor, data):
@pytest.mark.parametrize('scorer,processor',
full_scorers_processors())
@given(data=st.data())
@settings(max_examples=100)
@settings(max_examples=20, deadline=5000)
def test_only_identical_strings_extracted(scorer, processor, data):
"""
Test that only identical (post processing) strings score 100 on the test.
Expand All @@ -114,8 +122,11 @@ def test_only_identical_strings_extracted(scorer, processor, data):
"""
# Draw a list of random strings
strings = data.draw(
st.lists(st.text(min_size=10, max_size=100),
min_size=1, max_size=50))
st.lists(
st.text(min_size=10, max_size=100, alphabet=HYPOTHESIS_ALPHABET),
min_size=1,
max_size=10)
)
# Draw a random integer for the index in that list
choiceidx = data.draw(st.integers(min_value=0, max_value=(len(strings) - 1)))

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -3,7 +3,7 @@ envlist = py26, py27, py33, py34, py35, py36, pypy, pypy3
skip_missing_interpreters = True

[testenv]
deps = pytest
deps = pytest==3.2.5
pycodestyle
hypothesis
commands = py.test
Expand Down

0 comments on commit 61574c9

Please sign in to comment.