Esempio n. 1
0
    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)
Esempio n. 2
0
 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)
Esempio n. 3
0
 def teardown(self):
     virtualtime.disable()
     datetime.datetime.localtz_override = None
     unpatch_vt_module()
     test_datetime_tz.unpatch_datetime_module()
Esempio n. 4
0
 def tearDown(self):
     """Ensure that virtualtime is disabled after running each test"""
     while virtualtime.enabled():
         virtualtime.disable()
Esempio n. 5
0
 def setUp(self):
     while virtualtime.enabled():
         virtualtime.disable()
Esempio n. 6
0
 def teardown_class(cls):
     virtualtime.disable()
Esempio n. 7
0
 def setup_class(cls):
     virtualtime.disable()
Esempio n. 8
0
 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()
Esempio n. 9
0
 def teardown(self):
     virtualtime.disable()
     datetime.datetime.localtz_override = None
     unpatch_vt_module()
     test_datetime_tz.unpatch_datetime_module()
Esempio n. 10
0
 def tearDown(self):
     """Ensure that virtualtime is disabled after running each test"""
     while virtualtime.enabled():
         virtualtime.disable()
Esempio n. 11
0
 def setUp(self):
     while virtualtime.enabled():
         virtualtime.disable()
Esempio n. 12
0
 def teardown_class(cls):
     virtualtime.disable()
Esempio n. 13
0
 def setup_class(cls):
     virtualtime.disable()
Esempio n. 14
0
 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()