Skip to content

Commit

Permalink
Update test_validation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Sep 9, 2019
1 parent 7177a65 commit 6fd32b0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion hypothesis-python/src/hypothesis/internal/coverage.py
Expand Up @@ -50,7 +50,8 @@ def pretty_file_name(f):
pass

parts = f.split(os.path.sep)
parts = parts[-parts[::-1].index("hypothesis") :]
if "hypothesis" in parts:
parts = parts[-parts[::-1].index("hypothesis") :]
result = os.path.sep.join(parts)
pretty_file_name_cache[f] = result
return result
Expand Down
10 changes: 6 additions & 4 deletions hypothesis-python/tests/cover/test_validation.py
Expand Up @@ -253,8 +253,10 @@ def test(x):
def test_check_type_with_tuple_of_length_two():
# This test covers logic for length-two tuples that is essential on PY2,
# e.g. string_types (str, unicode) which are all length-one on Python 3.
check_type((int, str), 1)
check_type((int, str), "1")
def type_checker(x):
check_type((int, str), x, "x")

with pytest.raises(InvalidArgument):
check_type((int, str), 1.0)
type_checker(1)
type_checker("1")
with pytest.raises(InvalidArgument, match="Expected one of int, str but got "):
type_checker(1.0)

0 comments on commit 6fd32b0

Please sign in to comment.