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