diff --git a/django_nose/fixture_tables.py b/django_nose/fixture_tables.py index 7865e90..d7ced70 100644 --- a/django_nose/fixture_tables.py +++ b/django_nose/fixture_tables.py @@ -38,7 +38,7 @@ def read(self): return zipfile.ZipFile.read(self, self.namelist()[0]) compression_types = { - None: file, + None: open, 'gz': gzip.GzipFile, 'zip': SingleZipReader } @@ -125,6 +125,8 @@ def read(self): loaded_objects_in_fixture += 1 tables.add( obj.object.__class__._meta.db_table) + for x in obj.object.__class__._meta.local_many_to_many: + tables.add(x.m2m_db_table()) loaded_object_count += loaded_objects_in_fixture fixture_object_count += objects_in_fixture label_found = True diff --git a/django_nose/testcases.py b/django_nose/testcases.py index a899ec3..a3a38f4 100644 --- a/django_nose/testcases.py +++ b/django_nose/testcases.py @@ -88,6 +88,7 @@ def _fixture_teardown(cls): if tables: connection = connections[db] cursor = connection.cursor() + qn = connection.ops.quote_name # TODO: Rather than assuming that anything added to by a # fixture can be emptied, remove only what the fixture @@ -104,7 +105,7 @@ def _fixture_teardown(cls): cursor.execute('SET FOREIGN_KEY_CHECKS=1') else: for table in tables: - cursor.execute('DELETE FROM %s' % table) + cursor.execute('DELETE FROM %s' % qn(table)) transaction.commit(using=db) # cursor.close() # Should be unnecessary, since we committed