def test_same_file_produced_by_import_test_data_fast(self): # This is awful: we do some sys.module munging in settings.base to # globally replace sqlite3 with pysqlite3. However we were also using # `iterdump` as a lazy way of comparing the contents of two databases # and it turns out that pysqlite3 doesn't include that. So we # temporarily undo the monkey patch and grab `iterdump` from the # stdlib. Nice. orig_sqlite3 = sys.modules.pop("sqlite3") from sqlite3.dump import _iterdump sys.modules["sqlite3"] = orig_sqlite3 other_connection = sqlite3.connect(":memory:") import_test_data_fast( other_connection, self.data_factory, self.end_date, self.number_of_months ) db_dump = list(_iterdump(self.connection)) other_db_dump = list(_iterdump(other_connection)) self.assertEqual(db_dump, other_db_dump)
def iterdump(self): from sqlite3.dump import _iterdump return _iterdump(self)