Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small fixes for use with python 3.4, postgres, and many-to-many relations #165

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion django_nose/fixture_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion django_nose/testcases.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down