#29257: If creation of a db cursor fails, the resulting traceback is misleading
-------------------------------------+-------------------------------------
Reporter: Jerome Leclanche | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Chetan Khanna):
Hi.
Upon applying the patch, the following Traceback occurs since the asserted
output didn't match the new error raised. Just wanted to the correct way
to proceed from here (Sorry am very new here). Particularly, is a new
regression test required here? Or we just need to re-write these tests?
Traceback:
{{{
======================================================================
ERROR [0.006s]: test_atomic_prevents_queries_in_broken_transaction
(transactions.tests.AtomicErrorsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/unittest/case.py", line 59, in
testPartExecutor
yield
File "/usr/local/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/tests/django/tests/transactions/tests.py", line 327, in
test_atomic_prevents_queries_in_broken_transaction
r2.save(force_update=True)
File "/tests/django/django/db/models/base.py", line 743, in save
force_update=force_update, update_fields=update_fields)
File "/tests/django/django/db/models/base.py", line 781, in save_base
force_update, using, update_fields,
File "/tests/django/django/db/models/base.py", line 863, in _save_table
raise DatabaseError("Forced update did not affect any rows.")
django.db.utils.DatabaseError: Forced update did not affect any rows.
======================================================================
ERROR [0.160s]: test_content_type_rename_conflict
(contenttypes_tests.test_operations.ContentTypeOperationsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/unittest/case.py", line 59, in
testPartExecutor
yield
File "/usr/local/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/tests/django/tests/contenttypes_tests/test_operations.py", line
77, in test_content_type_rename_conflict
call_command('migrate', 'contenttypes_tests', database='default',
interactive=False, verbosity=0)
File "/tests/django/django/core/management/__init__.py", line 168, in
call_command
return command.execute(*args, **defaults)
File "/tests/django/django/core/management/base.py", line 369, in
execute
output = self.handle(*args, **options)
File "/tests/django/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/tests/django/django/core/management/commands/migrate.py", line
233, in handle
fake_initial=fake_initial,
File "/tests/django/django/db/migrations/executor.py", line 117, in
migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "/tests/django/django/db/migrations/executor.py", line 147, in
_migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "/tests/django/django/db/migrations/executor.py", line 245, in
apply_migration
state = migration.apply(state, schema_editor)
File "/tests/django/django/db/migrations/migration.py", line 124, in
apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File "/tests/django/django/db/migrations/operations/special.py", line
190, in database_forwards
self.code(from_state.apps, schema_editor)
File "/tests/django/django/contrib/contenttypes/management/__init__.py",
line 39, in rename_forward
self._rename(apps, schema_editor, self.old_model, self.new_model)
File "/tests/django/django/contrib/contenttypes/management/__init__.py",
line 27, in _rename
content_type.save(using=db, update_fields={'model'})
File "/tests/django/django/db/models/base.py", line 743, in save
force_update=force_update, update_fields=update_fields)
File "/tests/django/django/db/models/base.py", line 781, in save_base
force_update, using, update_fields,
File "/tests/django/django/db/models/base.py", line 865, in _save_table
raise DatabaseError("Save with update_fields did not affect any
rows.")
django.db.utils.DatabaseError: Save with update_fields did not affect any
rows.
======================================================================
FAIL [0.008s]: test_select_on_save_lying_update
(basic.tests.SelectOnSaveTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/unittest/case.py", line 59, in
testPartExecutor
yield
File "/usr/local/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/tests/django/tests/basic/tests.py", line 666, in
test_select_on_save_lying_update
asos.save(update_fields=['pub_date'])
File "/usr/local/lib/python3.6/contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "/tests/django/django/test/testcases.py", line 655, in
_assert_raises_or_warns_cm
self.assertIn(expected_message, str(getattr(cm, cm_attr)))
File "/usr/local/lib/python3.6/unittest/case.py", line 1089, in assertIn
self.fail(self._formatMessage(msg, standardMsg))
File "/usr/local/lib/python3.6/unittest/case.py", line 670, in fail
raise self.failureException(msg)
AssertionError: "An error occurred in the current transaction. You can't
execute queries until the end of the 'atomic' block." not found in 'Save
with update_fields did not affect any rows.'
======================================================================
FAIL [0.004s]: test_migrate_with_existing_target_permission
(auth_tests.test_migrations.ProxyModelWithSameAppLabelTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.6/unittest/case.py", line 59, in
testPartExecutor
yield
File "/usr/local/lib/python3.6/unittest/case.py", line 605, in run
testMethod()
File "/tests/django/tests/auth_tests/test_migrations.py", line 179, in
test_migrate_with_existing_target_permission
self.assertIn('A problem arose migrating proxy model permissions',
stdout.getvalue())
File "/usr/local/lib/python3.6/unittest/case.py", line 1089, in assertIn
self.fail(self._formatMessage(msg, standardMsg))
File "/usr/local/lib/python3.6/unittest/case.py", line 670, in fail
raise self.failureException(msg)
AssertionError: 'A problem arose migrating proxy model permissions' not
found in ''
----------------------------------------------------------------------
Ran 13026 tests in 230.826s
FAILED (failures=2, errors=2, skipped=779, expected failures=4)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29257#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/068.e4ca21bc83bfbb37de90e6b1cfb9bb13%40djangoproject.com.