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

Issues with tests when using mongodb #18

Open
chelis opened this issue Mar 24, 2015 · 1 comment
Open

Issues with tests when using mongodb #18

chelis opened this issue Mar 24, 2015 · 1 comment

Comments

@chelis
Copy link

chelis commented Mar 24, 2015

Using version 1.6.8 I get the following error when running tests

Traceback (most recent call last):
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/test/testcases.py", line 187, in call
self._post_teardown()
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/test/testcases.py", line 796, in _post_teardown
self._fixture_teardown()
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/test/testcases.py", line 889, in _fixture_teardown
return super(TestCase, self)._fixture_teardown()
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/test/testcases.py", line 817, in _fixture_teardown
inhibit_post_syncdb=self.available_apps is not None)
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/core/management/init.py", line 159, in call_command
return klass.execute(_args, *_defaults)
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(_args, *_options)
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/core/management/commands/flush.py", line 79, in handle_noargs
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/core/management/commands/flush.py", line 67, in handle_noargs
savepoint=connection.features.can_rollback_ddl):
File "/home/chelis/development/python/Envs/UnifiedPatents/local/lib/python2.7/site-packages/django/db/transaction.py", line 251, in enter
"The outermost 'atomic' block cannot use "
CommandError: Database test_patent_litigation couldn't be flushed. Possible reasons:

  • The database isn't running or isn't configured correctly.
  • At least one of the expected database tables doesn't exist.
  • The SQL was invalid.
    Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
    The full error: The outermost 'atomic' block cannot use savepoint = False when autocommit is off.

according to this post http://stackoverflow.com/questions/28520599/django-nonrel-mongodb-error-while-running-tests it runs with 1.5. Looking at djangos doc, 1.6 changed transaction behavior

https://docs.djangoproject.com/en/1.6/topics/db/transactions/

Changed in Django 1.6:
Before Django 1.6, autocommit was turned off, and it was emulated by forcing a commit after write operations in the ORM.

So I guess that's the reason of this issue.

@No-0n3
Copy link

No-0n3 commented Apr 18, 2015

Hi,

I can confirm that I get the same error.

Running: ./manage.py test polls
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line 187, in call
self._post_teardown()
File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line 796, in _post_teardown
self._fixture_teardown()
File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line 889, in _fixture_teardown
return super(TestCase, self)._fixture_teardown()
File "/usr/lib/python2.7/site-packages/django/test/testcases.py", line 817, in _fixture_teardown
inhibit_post_syncdb=self.available_apps is not None)
File "/usr/lib/python2.7/site-packages/django/core/management/init.py", line 159, in call_command
return klass.execute(_args, *_defaults)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(_args, *_options)
File "/usr/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/usr/lib/python2.7/site-packages/django/core/management/commands/flush.py", line 79, in handle_noargs
six.reraise(CommandError, CommandError(new_msg), sys.exc_info()[2])
File "/usr/lib/python2.7/site-packages/django/core/management/commands/flush.py", line 67, in handle_noargs
savepoint=connection.features.can_rollback_ddl):
File "/usr/lib/python2.7/site-packages/django/db/transaction.py", line 251, in enter
"The outermost 'atomic' block cannot use "
CommandError: Database test_rpi_2 couldn't be flushed. Possible reasons:

  • The database isn't running or isn't configured correctly.
  • At least one of the expected database tables doesn't exist.
  • The SQL was invalid.
    Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
    The full error: The outermost 'atomic' block cannot use savepoint = False when autocommit is off.

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

No branches or pull requests

2 participants