Opened 14 years ago
Last modified 12 years ago
#16250 closed Bug
Error with pyscopg2 and tests — at Version 6
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.3 |
Severity: | Release blocker | Keywords: | |
Cc: | ampledata, diegueus9@…, Apostolis Bessas, Gábor Farkas, mikeocool, shai@…, simonotron | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The test command doesn't work with psycopg2==2.4.2 but does with 2.4.1:
Creating test database for alias 'default'... Traceback (most recent call last): File "manage.py", line 14, in <module> execute_manager(settings) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager utility.execute() File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv self.execute(*args, **options.__dict__) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute output = self.handle(*args, **options) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/core/management/commands/test.py", line 37, in handle failures = test_runner.run_tests(test_labels) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/test/simple.py", line 359, in run_tests old_config = self.setup_databases() File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/test/simple.py", line 296, in setup_databases test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/db/backends/creation.py", line 351, in create_test_db self._create_test_db(verbosity, autoclobber) File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/db/backends/creation.py", line 416, in _create_test_db self.set_autocommit() File "/home/diegueus9/webapps/domicilios/lib/python2.7/site-packages/django/db/backends/creation.py", line 472, in set_autocommit self.connection.connection.autocommit = True psycopg2.ProgrammingError: autocommit cannot be used inside a transaction
Change History (6)
comment:1 by , 14 years ago
Cc: | added |
---|
comment:2 by , 14 years ago
The quick fix seems to reverse the test and check for the existence of set_isolation_level before autocommit.
The proper fix is to add a set_autocommit method to the specific database driver.
comment:3 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 14 years ago
Opened a discussion about the issue in the psycopg ML.
http://archives.postgresql.org/psycopg/2011-06/msg00028.php
comment:5 by , 14 years ago
Also note that if the exception is raised it means that you have already started a transaction somehow. Asking for autocommit with a transaction already in progress is asking the drivers to be generous and give you a rollback at best. A correct behaviour for a more robust set_autocommit() could be to call connection.rollback() as well.
comment:6 by , 14 years ago
Description: | modified (diff) |
---|
Going out on a limb and guessing this is due to the transaction control 'overhaul' in Psycopg 2.4.2:
Para: http://www.initd.org/psycopg/articles/2011/06/12/psycopg-242-released/