From 6fd32b04d4e8feed9a80ddd3f6cb3d438d38393c Mon Sep 17 00:00:00 2001 From: Zac-HD Date: Tue, 10 Sep 2019 07:15:13 +1000 Subject: [PATCH] Update test_validation.py --- hypothesis-python/src/hypothesis/internal/coverage.py | 3 ++- hypothesis-python/tests/cover/test_validation.py | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/hypothesis-python/src/hypothesis/internal/coverage.py b/hypothesis-python/src/hypothesis/internal/coverage.py index 922e99d284..a4d27e3829 100644 --- a/hypothesis-python/src/hypothesis/internal/coverage.py +++ b/hypothesis-python/src/hypothesis/internal/coverage.py @@ -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 diff --git a/hypothesis-python/tests/cover/test_validation.py b/hypothesis-python/tests/cover/test_validation.py index 44ada18523..02bb83a596 100644 --- a/hypothesis-python/tests/cover/test_validation.py +++ b/hypothesis-python/tests/cover/test_validation.py @@ -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)