summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLabrys of Knossos <Labrys.git@gmail.com>2019-07-08 19:45:58 -0400
committerPaul Ganssle <paul@ganssle.io>2019-11-02 11:01:07 -0400
commit16bfee76aa13c1186d0f7150ee1a6c7651abd63e (patch)
treec2b99b34915d9671d3bd1553a454f7d71dc35a2c
parentefb3e5e4038e1970697ea7a542f60a73a3ae419c (diff)
downloaddateutil-git-16bfee76aa13c1186d0f7150ee1a6c7651abd63e.tar.gz
Add tests for gettz zone supports startswith
-rw-r--r--dateutil/test/test_tz.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py
index aac4f4b..cd54eb9 100644
--- a/dateutil/test/test_tz.py
+++ b/dateutil/test/test_tz.py
@@ -1103,6 +1103,36 @@ def test_gettz_badzone_unicode():
@pytest.mark.gettz
+@pytest.mark.parametrize(
+ "badzone,exc_reason",
+ [
+ pytest.param(
+ b"America/New_York",
+ ".*should be str, not bytes.*",
+ id="bytes on Python 3",
+ marks=[
+ pytest.mark.skipif(
+ PY2, reason="bytes arguments accepted in Python 2"
+ )
+ ],
+ ),
+ pytest.param(
+ object(),
+ None,
+ id="no startswith()",
+ marks=[
+ pytest.mark.xfail(reason="AttributeError instead of TypeError",
+ raises=AttributeError),
+ ],
+ ),
+ ],
+)
+def test_gettz_zone_wrong_type(badzone, exc_reason):
+ with pytest.raises(TypeError, match=exc_reason):
+ tz.gettz(badzone)
+
+
+@pytest.mark.gettz
@pytest.mark.xfail(IS_WIN, reason='zoneinfo separately cached')
def test_gettz_cache_clear():
NYC1 = tz.gettz('America/New_York')