Beispiel #1
0
 def set_up(self):
     if Person.metadata is None:
         reset_metadata()
         engine = create_engine('sqlite://')
         metadata = create_metadata(engine)
         Person.metadata = metadata
         metadata.bind = engine
     VisitorTestCase.set_up(self)
Beispiel #2
0
 def teardown_class(cls):
     base_cls = super(RdbTestCaseMixin, cls)
     try:
         base_cls.teardown_class()
     except AttributeError:
         pass
     Session.remove()
     assert not Session.registry.has()
     reset_metadata()
Beispiel #3
0
 def test_metadata_manager(self):
     key = 'test'
     self.assert_false(is_metadata_initialized(key))
     md = MetaData()
     set_metadata(key, md)
     self.assert_raises(ValueError, set_metadata, key, md)
     self.assert_true(is_metadata_initialized(key))
     self.assert_true(get_metadata(key) is md)
     reset_metadata()
     self.assert_false(is_metadata_initialized(key))
Beispiel #4
0
 def teardown_class(cls):
     reset_metadata()
Beispiel #5
0
def teardown():
    # Module level tear down.
    if not Person.metadata is None:
        Person.metadata.drop_all()
        Person.metadata = None
    reset_metadata()
Beispiel #6
0
 def _reset(self):
     # It is safe to keep the engine around, even for complex unit test
     # scenarios; the metadata, however, might change and need to be
     # removed.
     if is_metadata_initialized(self.name):
         reset_metadata()
Beispiel #7
0
 def set_up(self):
     if Person.metadata is None:
         reset_metadata()
         engine = create_engine('sqlite://')
         Person.metadata = create_metadata(engine)
     OrderVisitorTestCase.set_up(self)
Beispiel #8
0
 def tear_down():
     Session.remove()
     assert not Session.registry.has()
     reset_metadata()