def save_and_check(self, dataIn, tableIn, dataOut, tableOut = None, twice = True): if tableOut == None: tableOut = quote(tableIn) # Insert h = DumpTruck(dbname = '/tmp/test.db') h.insert(dataIn, tableIn) h.close() # Observe with pysqlite connection=sqlite3.connect('/tmp/test.db') cursor=connection.cursor() cursor.execute(u'SELECT * FROM %s' % tableOut) observed1 = cursor.fetchall() connection.close() if twice: # Observe with DumpTruck h = DumpTruck(dbname = '/tmp/test.db') observed2 = h.execute(u'SELECT * FROM %s' % tableOut) h.close() #Check expected1 = dataOut expected2 = [dataIn] if type(dataIn) in (dict, OrderedDict) else dataIn self.assertListEqual(observed1, expected1) self.assertListEqual(observed2, expected2)
def assertQuoteError(self, textIn): self.assertRaises(ValueError, lambda: quote(textIn))
def assertQuote(self, textIn, textOut): self.assertEqual(quote(textIn), textOut)