예제 #1
0
    def test_atexit(self):
        m = Mock()
        with Replacer() as r:
            r.replace('atexit.register', m.register)

            c = TestComponents()

            expected = [call.register(c.atexit)]

            compare(expected, m.mock_calls)

            with catch_warnings(record=True) as w:
                c.atexit()
                self.assertTrue(len(w), 1)
                compare(str(w[0].message), (  # pragma: no branch
                    "TestComponents instances not uninstalled by shutdown!"
                    ))

            c.uninstall()

            compare(expected, m.mock_calls)

            # check re-running has no ill effects
            c.atexit()

            compare(expected, m.mock_calls)
예제 #2
0
 def setUp(self):
     self.components = TestComponents()
     self.Base = declarative_base()
     class Model(self.Base):
         __tablename__ = 'model'
         id = Column('id', Integer, primary_key=True)
         name = Column('name', String(50))
     self.Model = Model
예제 #3
0
 def setUp(self):
     self.components = TestComponents()
     self.r = Replacer()
     self.m = Mock()
     self.r.replace('mortar_rdb.testing.real_register_session',
                    self.m.realRegisterSession)
     self.r.replace('mortar_rdb.testing.create_engine',
                    self.m.create_engine)
     # mock out for certainty
     # self.r.replace('mortar_rdb.testing.???',Mock())
     # mock out for table destruction
     get_session = Mock()
     bind = get_session.return_value.bind
     bind.dialect.inspector.return_value = inspector = Mock()
     inspector.get_table_names.return_value = ()
     self.r.replace('mortar_rdb.testing.get_session', get_session)
예제 #4
0
 def setUp(self):
     self.dir = TempDirectory()
     self.components = TestComponents()
예제 #5
0
 def setUp(self):
     self.components = TestComponents()