Esempio n. 1
0
 def __iter__(self):
     try:
         # Reset the session.
         LaunchpadLayer.resetSessionDb()
         # Yield control to asyncore for a second, just to be a
         # little bit nice.  We could be even nicer by moving this
         # whole teardown/setup dance to a thread and waiting for
         # it to be done, but there's not a (known) compelling need
         # for that right now, and doing it this way is slightly
         # simpler.
         yield ''
         DatabaseLayer.testSetUp()
         yield ''
         # Reset the librarian.
         LibrarianLayer.testTearDown()
         yield ''
         # Reset the database.
         DatabaseLayer.testTearDown()
         yield ''
         LibrarianLayer.testSetUp()
     except (SystemExit, KeyboardInterrupt):
         raise
     except:
         print "Hm, serious error when trying to clean up the test."
         traceback.print_exc()
     # We're done, so we can yield the body.
     yield '\n'
 def test_db_is_reset(self):
     con = DatabaseLayer.connect()
     cur = con.cursor()
     cur.execute("DELETE FROM Wikiname")
     self.failUnlessEqual(self.getWikinameCount(con), 0)
     con.commit()
     # Run the per-test code for the Database layer.
     DatabaseLayer.testTearDown()
     DatabaseLayer.testSetUp()
     # Wikiname table should have been restored.
     con = DatabaseLayer.connect()
     self.assertNotEqual(0, self.getWikinameCount(con))
Esempio n. 3
0
 def test_db_is_reset(self):
     con = DatabaseLayer.connect()
     cur = con.cursor()
     cur.execute("DELETE FROM Wikiname")
     self.failUnlessEqual(self.getWikinameCount(con), 0)
     con.commit()
     # Run the per-test code for the Database layer.
     DatabaseLayer.testTearDown()
     DatabaseLayer.testSetUp()
     # Wikiname table should have been restored.
     con = DatabaseLayer.connect()
     self.assertNotEqual(0, self.getWikinameCount(con))