Exemplo n.º 1
0
def deepstar_path():
    with tempdir() as tempdir_:
        with mock.patch.dict(os.environ, {'DEEPSTAR_PATH': tempdir_}):
            Deepstar.init()

            try:
                yield
            finally:
                Model.close()
Exemplo n.º 2
0
 def test_isolation_level(self):
     with deepstar_path():
         Model.db.execute('CREATE TABLE test (test TEXT)')
         Model.db.execute("INSERT INTO test (test) VALUES ('test')")
         Model.close()
         Model.init()
         self.assertEqual(
             Model.db.execute('SELECT test FROM test').fetchone(),
             ('test', ))  # noqa
Exemplo n.º 3
0
    def test_check_same_thread(self):
        with deepstar_path():

            def a():
                Model.init()

            thread = threading.Thread(target=a)

            Model.close()

            thread.start()

            thread.join()

            Model.close()
Exemplo n.º 4
0
 def test_close(self):
     with deepstar_path():
         Model.close()
         self.assertEqual(Model.db, None)