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