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

Fix for https://github.com/django-nose/django-nose/issues/197 #207

Merged
merged 5 commits into from
Jul 7, 2015

Conversation

scottsexton
Copy link
Contributor

Stop using transaction.commit_unless_managed, and add keepdb kwarg to _skip_create_test_db().

#197

@scottsexton scottsexton changed the title Stop using transaction.commit_unless_managed, and Fix for https://github.com/django-nose/django-nose/issues/197 Apr 28, 2015
@@ -381,7 +381,8 @@ def _foreign_key_ignoring_handle(self, *fixture_labels, **options):
connection.close()


def _skip_create_test_db(self, verbosity=1, autoclobber=False, serialize=True):
def _skip_create_test_db(self, verbosity=1, autoclobber=False, serialize=True,
keepdb=True):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you adding the new variable keepdb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This keyword arg is passed now by Django 1.8, so it needs to be added here to prevent the following error:

File "/[directory_path]/lib/python2.7/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
TypeError: _skip_create_test_db() got an unexpected keyword argument 'keepdb'

This is the same reason the serialize argument was added for 1.7 in this fix: 4c9cf02

@ayc92
Copy link

ayc92 commented Apr 29, 2015

In the FastFixtureTestCase class's setUpClass class method, it uses the function from django.db.transaction transaction.enter_transaction_management, which no longer exists in 1.8. I'm not sure what the equivalent function in 1.8 would be. Maybe transaction.set_auto?

@scottsexton
Copy link
Contributor Author

@ayc92 You're right, this pull request is not addressing the whole issue of Django legacy transaction management. I am only fixing REUSE_DB=1 here. I'll close this pull request so that someone familiar with FastFixtureTestCase (@erikrose?) can update their code with a more holistic solution.

@scottsexton
Copy link
Contributor Author

People keep asking for REUSE_DB to work again, which is what this pull request addresses. What is not addressed here is the legacy transaction management in FastFixtureTestCase. Perhaps someone can do a different fix for that. Until then, there's no reason to not fix REUSE_DB.

@scottsexton scottsexton reopened this Jun 12, 2015
@KevinGrahamFoster
Copy link

Awesome, thanks Scott!

@jwhitlock
Copy link
Contributor

@scottsexton - can you rebase this change on the new master (git rebase -i master or similar), and resubmit?

I've made significant changes to the project, which includes:

  • Adding some basic database tests
  • Adding REUSE_DB=1 tests to runtests.sh
  • Getting this bug to reproduce in TravisCI:

https://travis-ci.org/django-nose/django-nose
https://travis-ci.org/django-nose/django-nose/jobs/69352051 (Python 2.7, Django 1.8, with PostgreSQL)

I can also reproduce it locally with Python 3.4, Django 1.8.1, and SQLite with runtest.sh and REUSE_DB=1 ./manage.py test. Python 2.7 seems to work, which makes me think there is still something buggy with the REUSE_DB code paths.

@jwhitlock jwhitlock added this to the Database Testing milestone Jul 2, 2015
Conflicts:
	django_nose/runner.py
@scottsexton
Copy link
Contributor Author

@jwhitlock Rebased as requested! Tests pass :)

jwhitlock added a commit that referenced this pull request Jul 7, 2015
@jwhitlock jwhitlock merged commit 7cf2d6b into jazzband:master Jul 7, 2015
@jwhitlock jwhitlock modified the milestones: v1.4.2, Database Testing Jul 7, 2015
@shanukus98765
Copy link

@scottsexton
I am getting this error. Any idea how to go about this? The legacy transaction management support has changed in Django 1.8 and is there something to tackle this?

ERROR: test suite for <class 'texparser.tests.test_views.TexparserTestCase'>

Traceback (most recent call last):
File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 209, in run
self.setUp()
File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 292, in setUp
self.setupContext(ancestor)
File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/suite.py", line 315, in setupContext
try_run(context, names)
File "/home/shanu/.virtualenvs/typeset_dev/local/lib/python2.7/site-packages/nose/util.py", line 471, in try_run
return func()
File "/home/shanu/typeset_revamped/typeset/libs/django_nose/testcases.py", line 50, in setUpClass
transaction.enter_transaction_management(using=db)
AttributeError: 'module' object has no attribute 'enter_transaction_management'

@jwhitlock
Copy link
Contributor

@shanukus98765 this has been merged into master, and is passing tests in TravisCI under Django 1.8 with a few database backends. I think it deserves a new issue to determine what is different under your setup.

@shanukus98765
Copy link

@jwhitlock Opened up a new issue.

@rrauenza
Copy link

rrauenza commented May 2, 2016

@shanukus98765 where is the issue you opened? I'm having a similar issue with Django 1.8 and Djang-Nose 1.4.3.

Found it: #226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants