def test_switching(self): orig_datetime = datetime.datetime class derived_datetime(datetime.datetime): pass assert issubclass(datetime_tz.datetime_tz, orig_datetime) assert issubclass(datetime_tz.datetime_tz, datetime.datetime) assert issubclass(derived_datetime, orig_datetime) assert issubclass(derived_datetime, datetime.datetime) virtualtime.enable() class derived_datetime2(datetime.datetime): pass assert issubclass(datetime_tz.datetime_tz, orig_datetime) assert issubclass(datetime_tz.datetime_tz, datetime.datetime) assert issubclass(derived_datetime, orig_datetime) assert issubclass(derived_datetime, datetime.datetime) assert issubclass(derived_datetime2, orig_datetime) assert issubclass(derived_datetime2, datetime.datetime) virtualtime.disable() assert issubclass(datetime_tz.datetime_tz, orig_datetime) assert issubclass(datetime_tz.datetime_tz, datetime.datetime) assert issubclass(derived_datetime, orig_datetime) assert issubclass(derived_datetime, datetime.datetime) assert issubclass(derived_datetime2, orig_datetime) assert issubclass(derived_datetime2, datetime.datetime)
def teardown(self): virtualtime.disable() datetime.datetime.localtz_override = None unpatch_vt_module() test_datetime_tz.unpatch_datetime_module()
def tearDown(self): """Ensure that virtualtime is disabled after running each test""" while virtualtime.enabled(): virtualtime.disable()
def setUp(self): while virtualtime.enabled(): virtualtime.disable()
def teardown_class(cls): virtualtime.disable()
def setup_class(cls): virtualtime.disable()
def teardown_class(cls): """Ensure that virtualtime was enabled when running these tests, but disabled after""" del cls.virtual_time_enabled assert virtualtime.enabled() virtualtime.disable() assert not virtualtime.enabled()