As of March 21, 2014, some legacy transaction management features in the Django project have been deprecated and removed from the project: django/[email protected].
I have a Makefile with the following (among other things):
COMMON_REQUIREMENTS_FILE = arcadia/config/environments/common/requirements.txt
DEVELOPMENT_REQUIREMENTS_FILE = arcadia/config/environments/development/requirements.txt
TESTING_DATABASE_NAME = test_arcadia
TESTING_DATABASE_OWNER = arcadia
TESTING_SETTINGS_FILE = arcadia.config.environments.testing.settings
test:
REUSE_DB=1 python manage.py test --settings $(TESTING_SETTINGS_FILE)
test-clean:
sudo su - postgres -c 'psql -c "DROP DATABASE IF EXISTS $(TESTING_DATABASE_NAME);"'
sudo su - postgres -c 'psql -c "CREATE DATABASE $(TESTING_DATABASE_NAME) WITH OWNER $(TESTING_DATABASE_OWNER);"'
pip install -r $(COMMON_REQUIREMENTS_FILE)
pip install -r $(DEVELOPMENT_REQUIREMENTS_FILE)
python manage.py makemigrations --settings $(TESTING_SETTINGS_FILE)
python manage.py migrate --settings $(TESTING_SETTINGS_FILE)
REUSE_DB=1 python manage.py test --settings $(TESTING_SETTINGS_FILE)
Running make test-clean
produces the following:
sudo su - postgres -c 'psql -c "DROP DATABASE IF EXISTS test_arcadia;"'
NOTICE: database "test_arcadia" does not exist, skipping
DROP DATABASE
sudo su - postgres -c 'psql -c "CREATE DATABASE test_arcadia WITH OWNER arcadia;"'
CREATE DATABASE
pip install -r arcadia/config/environments/common/requirements.txt
Requirement already satisfied (use --upgrade to upgrade): Django==1.8 i /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/common/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): psycopg2==2.6 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/common/requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): django-compressor==1.4 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/common/requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): django-appconf>=0.4 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from django-compressor==1.4->-r arcadia/config/environments/common/requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): six in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from django-appconf>=0.4->django-compressor==1.4->-r arcadia/config/environments/common/requirements.txt (line 3))
pip install -r arcadia/config/environments/development/requirements.txt
Obtaining file:///home/james/workspace/django-nose (from -r arcadia/config/environments/development/requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): django-debug-toolbar==1.3.0 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/development/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): django-extensions==1.5.2 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/development/requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): nose==1.3.6 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from -r arcadia/config/environments/development/requirements.txt (line 3))
Requirement already satisfied (use --upgrade to upgrade): Django>=1.4 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from django-nose==1.3->-r arcadia/config/environments/development/requirements.txt (line 5))
Requirement already satisfied (use --upgrade to upgrade): sqlparse in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from django-debug-toolbar==1.3.0->-r arcadia/config/environments/development/requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): six>=1.2 in /home/james/.virtualenvs/arcadia/lib/python2.7/site-packages (from django-extensions==1.5.2->-r arcadia/config/environments/development/requirements.txt (line 2))
Installing collected packages: django-nose
Running setup.py develop for django-nose
Successfully installed django-nose-1.3
python manage.py makemigrations --settings arcadia.config.environments.testing.settings
No changes detected
python manage.py migrate --settings arcadia.config.environments.testing.settings
Operations to perform:
Synchronize unmigrated apps: members, staticfiles, messages, compressor, authentication, django_nose
Apply all migrations: admin, contenttypes, sites, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
REUSE_DB=1 python manage.py test --settings arcadia.config.environments.testing.settings nosetests --verbosity=1
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/home/james/workspace/django-nose/django_nose/runner.py", line 349, in run_tests
result = self.run_suite(nose_argv)
File "/home/james/workspace/django-nose/django_nose/runner.py", line 296, in run_suite
addplugins=plugins_to_add)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
**extra_args)
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 207, in runTests
result = self.testRunner.run(self.test)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 50, in run
wrapper = self.config.plugins.prepareTest(test)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "/home/james/workspace/django-nose/django_nose/plugin.py", line 76, in prepareTest
self.old_names = self.runner.setup_databases()
File "/home/james/workspace/django-nose/django_nose/runner.py", line 521, in setup_databases
transaction.commit_unless_managed(using=connection.alias)
AttributeError: 'module' object has no attribute 'commit_unless_managed'
make: *** [test-clean] Error 1
Running make test
produces the same error:
REUSE_DB=1 python manage.py test --settings arcadia.config.environments.testing.settings nosetests --verbosity=1
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
super(Command, self).execute(*args, **options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
failures = test_runner.run_tests(test_labels)
File "/home/james/workspace/django-nose/django_nose/runner.py", line 349, in run_tests
result = self.run_suite(nose_argv)
File "/home/james/workspace/django-nose/django_nose/runner.py", line 296, in run_suite
addplugins=plugins_to_add)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 121, in __init__
**extra_args)
File "/usr/lib/python2.7/unittest/main.py", line 95, in __init__
self.runTests()
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 207, in runTests
result = self.testRunner.run(self.test)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/core.py", line 50, in run
wrapper = self.config.plugins.prepareTest(test)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 99, in __call__
return self.call(*arg, **kw)
File "/home/james/.virtualenvs/arcadia/local/lib/python2.7/site-packages/nose/plugins/manager.py", line 167, in simple
result = meth(*arg, **kw)
File "/home/james/workspace/django-nose/django_nose/plugin.py", line 76, in prepareTest
self.old_names = self.runner.setup_databases()
File "/home/james/workspace/django-nose/django_nose/runner.py", line 521, in setup_databases
transaction.commit_unless_managed(using=connection.alias)
AttributeError: 'module' object has no attribute 'commit_unless_managed'
make: *** [test] Error 1
This error doesn't occur after I remove sudo su - postgres -c 'psql -c "CREATE DATABASE $(TESTING_DATABASE_NAME) WITH OWNER $(TESTING_DATABASE_OWNER);
from test-clean
, but make test
still causes it to happen.
Running python manage.py test --settings arcadia.config.environments.testing.settings
from the command line also solves the problem.
Here is the offending line of code: django_nose/runner.py#L404.
Please let me know if I can provide anything else that is helpful.
bug