diff --git a/dateutil/test/test_tz.py b/dateutil/test/test_tz.py index 76669c9ff323b78a266c9f64711315130af0ad8a_ZGF0ZXV0aWwvdGVzdC90ZXN0X3R6LnB5..e79352db8d742c5bcab5ea5ed487cb18d48e04f2_ZGF0ZXV0aWwvdGVzdC90ZXN0X3R6LnB5 100644 --- a/dateutil/test/test_tz.py +++ b/dateutil/test/test_tz.py @@ -15,7 +15,6 @@ import base64 import copy import gc -import weakref from functools import partial @@ -733,18 +732,18 @@ assert tz1 is tz2 - -@pytest.mark.smoke -@pytest.mark.tzoffset -def test_tzoffset_weakref(): - UTC1 = tz.tzoffset('UTC', 0) - UTC_ref = weakref.ref(tz.tzoffset('UTC', 0)) - UTC1 is UTC_ref() - del UTC1 - gc.collect() - - assert UTC_ref() is None - assert UTC_ref() is not tz.tzoffset('UTC', 0) + def testTzOffsetWeakRef(self): + UTC1 = tz.tzoffset('UTC', 0) + UTC2 = tz.tzoffset('UTC', 0) + assert id(UTC1) == id(UTC2) + + weak_ref_id = id(UTC1) + del UTC1 + del UTC2 + gc.collect() + + UTC3 = tz.tzoffset('UTC', 0) + assert not weak_ref_id == id(UTC3) @pytest.mark.tzoffset @@ -1066,8 +1065,7 @@ @pytest.mark.xfail(IS_WIN, reason="Windows does not use system zoneinfo") -@pytest.mark.smoke @pytest.mark.gettz def test_gettz_weakref(): tz.gettz.cache_clear() NYC1 = tz.gettz('America/New_York') @@ -1070,9 +1068,9 @@ @pytest.mark.gettz def test_gettz_weakref(): tz.gettz.cache_clear() NYC1 = tz.gettz('America/New_York') - NYC_ref = weakref.ref(tz.gettz('America/New_York')) - - assert NYC1 is NYC_ref() - + NYC2 = tz.gettz('America/New_York') + assert id(NYC1) == id(NYC2) + + weak_ref_id = id(NYC1) del NYC1 @@ -1078,3 +1076,4 @@ del NYC1 + del NYC2 gc.collect() @@ -1079,7 +1078,7 @@ gc.collect() - assert NYC_ref() is None - assert tz.gettz('America/New_York') is not NYC_ref() + NYC3 = tz.gettz('America/New_York') + assert not weak_ref_id == id(NYC3) class ZoneInfoGettzTest(GettzTest, WarningTestMixin): @@ -1409,19 +1408,18 @@ # Ensure that these still are all the same zone assert tz1 == tz2 == tz3 - -@pytest.mark.smoke -@pytest.mark.tzstr -def test_tzstr_weakref(): - tz_t1 = tz.tzstr('EST5EDT') - tz_t2_ref = weakref.ref(tz.tzstr('EST5EDT')) - assert tz_t1 is tz_t2_ref() - - del tz_t1 - gc.collect() - - assert tz_t2_ref() is None - assert tz.tzstr('EST5EDT') is not tz_t2_ref() + def testTzOffsetWeakRef(self): + tz_t1 = tz.tzstr('EST5EDT') + tz_t2 = tz.tzstr('EST5EDT') + assert id(tz_t1) == id(tz_t2) + + weak_ref_id = id(tz_t1) + del tz_t1 + del tz_t2 + gc.collect() + + tz_t3 = tz.tzstr('EST5EDT') + assert not weak_ref_id == id(tz_t3) @pytest.mark.tzstr