MCPcopy Create free account
hub / github.com/dateutil/dateutil / test_gettz_weakref

Function test_gettz_weakref

tests/test_tz.py:1218–1239  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1216@pytest.mark.smoke
1217@pytest.mark.gettz
1218def test_gettz_weakref():
1219 tz.gettz.cache_clear()
1220 tz.gettz.set_cache_size(2)
1221 NYC1 = tz.gettz('America/New_York')
1222 NYC_ref = weakref.ref(tz.gettz('America/New_York'))
1223
1224 assert NYC1 is NYC_ref()
1225
1226 del NYC1
1227 gc.collect()
1228
1229 assert NYC_ref() is not None # Should still be in the strong cache
1230 assert tz.gettz('America/New_York') is NYC_ref()
1231
1232 # Populate strong cache with other timezones
1233 tz.gettz("Europe/Paris")
1234 tz.gettz("Pacific/Easter")
1235 tz.gettz("Australia/Hobart")
1236
1237 gc.collect()
1238 assert NYC_ref() is None # Should have been pushed out
1239 assert tz.gettz('America/New_York') is not NYC_ref()
1240
1241@requires_tzdata
1242class ZoneInfoGettzTest(GettzTest):

Callers

nothing calls this directly

Calls 3

cache_clearMethod · 0.80
set_cache_sizeMethod · 0.80
gettzMethod · 0.45

Tested by

no test coverage detected