a  zer @sddlZddlZddlZddlZddlZddlmZeZeZ eZ ddZ e ddZ ej ddZGd d d ejZdS) N)import_fresh_modulecs2ttd|t|fdd}|S)z;Decorator that ensures a function is only ever called once.Ncs.WdS1s 0YdSNrcachedlockrO/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_zoneinfo/_support.pyinnerszcall_once..inner) threadingLock functools lru_cachewraps)fr rrr call_once s rcCsddl}tddgd}||fS)uRetrieve two copies of zoneinfo: pure Python and C accelerated. Because this function manipulates the import system in a way that might be fragile or do unexpected things if it is run many times, it uses a `call_once` decorator to ensure that this is only ever called exactly one time — in other words, when using this function you will only ever get one copy of each module rather than a fresh import each time. rNzoneinfoZ _zoneinfo)Zblocked)rr)Zc_moduleZ py_modulerrr get_moduless rccsHt}tjd|}|tjd<dV||ur8|tjd<n tjddS)zMake sure sys.modules["zoneinfo"] refers to `module`. This is necessary because `pickle` will refuse to serialize an type calling itself `zoneinfo.ZoneInfo` unless `zoneinfo.ZoneInfo` refers to the same object. rN)objectsysmodulesgetpop)moduleZ NOT_PRESENTZ old_zoneinforrrset_zoneinfo_module+s   rcs4eZdZefddZejdefddZZ S)ZoneInfoTestBasecs|jj|_tdSr)rZZoneInfoklasssuper setUpClass)cls __class__rrr?s zZoneInfoTestBase.setUpClassTc csdd}||r"|}dtjd<|jj}zN|j|dVW|rltjd|D]\}}|tj|<qX|j|n:|rtjd|D]\}}|tj|<q|j|0Wdn1s0YdS)NcSs>i}ttjD]*}|ddddkr(qtj|||<q|S)N.rtzdata)listrrsplitr)tzdata_modulesmodnamerrrpop_tzdata_modulesFs z;ZoneInfoTestBase.tzpath_context..pop_tzdata_modulesr#)rrrZTZPATHZ reset_tzpathritems) selfZtzpathZ block_tzdatarr(r&Zold_pathr'rrrrtzpath_contextDs&       zZoneInfoTestBase.tzpath_context) __name__ __module__ __qualname__ classmethodr contextlibcontextmanager TZPATH_LOCKr+ __classcell__rrrrr>sr)r0r rr ZunittestZ test.supportrr Z OS_ENV_LOCKr2ZTZPATH_TEST_LOCKrrr1rZTestCaserrrrrs