Ejemplo n.º 1
0
 def setUp(self):
     # setting up a real db
     self.db = tempfile.NamedTemporaryFile(delete=False)
     self.conn = setup_db(self.db.name)
     cur = self.conn.cursor()
     _now = datetime.datetime.now().isoformat()
     cur.execute('''INSERT INTO fetched_msgs VALUES (?, ?)''',
                 (_now, 42))
     self.conn.commit()
Ejemplo n.º 2
0
    def test_setup(self):
        tmpfile = tempfile.NamedTemporaryFile()
        conn = setup_db(tmpfile.name)
        conn.close()

        testconn = sqlite3.connect(tmpfile.name)
        testcur = testconn.cursor()
        testcur.execute('''SELECT * FROM fetched_msgs''')
        print testcur.fetchall()
        # no errors have been raised at this point; test passed
        assert True