diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py index 91e3ecb3c..cd54eb913 100644 --- a/dateutil/test/test_tz.py +++ b/dateutil/test/test_tz.py @@ -1101,36 +1101,35 @@ def test_gettz_badzone_unicode(): tzi = tz.gettz('🐼') assert tzi is None - + @pytest.mark.gettz @pytest.mark.parametrize( - 'badzone', [ + "badzone,exc_reason", + [ pytest.param( - b'America/New_York', - id='bytes on python 3', + b"America/New_York", + ".*should be str, not bytes.*", + id="bytes on Python 3", marks=[ - pytest.mark.xfail( - raises=TypeError, - reason='bytes.startswith first arg must be bytes, not str', - ), pytest.mark.skipif( - sys.version_info < (3, 0), - reason='bytes are str in Python 2', + PY2, reason="bytes arguments accepted in Python 2" ) - ] + ], ), pytest.param( object(), - id='no startswith() method', - marks=pytest.mark.xfail( - raises=AttributeError, - reason='object must support startswith with str prefix', - ), - ) - ] + None, + id="no startswith()", + marks=[ + pytest.mark.xfail(reason="AttributeError instead of TypeError", + raises=AttributeError), + ], + ), + ], ) -def test_gettz_zone_startswith(badzone): - tz.gettz(badzone) +def test_gettz_zone_wrong_type(badzone, exc_reason): + with pytest.raises(TypeError, match=exc_reason): + tz.gettz(badzone) @pytest.mark.gettz