Opened 11 years ago

Closed 11 years ago

#21151 closed Bug (fixed)

Failures in the new schema tests

Reported by: Florian Apolloner Owned by: Andrew Godwin <andrew@…>
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: migrations, schema
Cc: Andrew Godwin Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

./runtests.py --settings=test_postgresql -v2 schema.tests.SchemaTests.test_m2m_repoint schema.tests.SchemaTests.test_m2m_create
Importing application schema
Creating test database for alias 'default' ('django_test')...
Operations to perform:
  Synchronize unmigrated apps: redirects, another_app, sessions, admin, admindocs, messages, sites, flatpages, staticfiles_tests, staticfiles, contenttypes, humanize, auth, test, schema, no_label, comments
  Apply all migrations: (none)
Synchronizing apps without migrations:
  Creating tables...
    Creating table django_content_type
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_site
    Creating table django_flatpage_sites
    Creating table django_flatpage
    Creating table django_redirect
    Creating table django_session
    Creating table django_comments
    Creating table django_comment_flags
    Creating table django_admin_log
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations needed.
Installed 0 object(s) from 0 fixture(s)
Creating test database for alias 'other' (':memory:')...
Operations to perform:
  Synchronize unmigrated apps: redirects, another_app, sessions, admin, admindocs, messages, sites, flatpages, staticfiles_tests, staticfiles, contenttypes, humanize, auth, test, schema, no_label, comments
  Apply all migrations: (none)
Synchronizing apps without migrations:
  Creating tables...
    Creating table django_content_type
    Creating table auth_permission
    Creating table auth_group_permissions
    Creating table auth_group
    Creating table auth_user_groups
    Creating table auth_user_user_permissions
    Creating table auth_user
    Creating table django_site
    Creating table django_flatpage_sites
    Creating table django_flatpage
    Creating table django_redirect
    Creating table django_session
    Creating table django_comments
    Creating table django_comment_flags
    Creating table django_admin_log
  Installing custom SQL...
  Installing indexes...
Running migrations:
  No migrations needed.
Installed 0 object(s) from 0 fixture(s)
test_m2m_repoint (schema.tests.SchemaTests) ... ok
test_m2m_create (schema.tests.SchemaTests) ... ERROR
ERROR
ERROR

======================================================================
ERROR: test_m2m_create (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/tests/schema/tests.py", line 229, in test_m2m_create
    editor.create_model(BookWithM2M)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 78, in __exit__
    self.execute(sql)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 94, in execute
    cursor.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
ProgrammingError: relation "schema_bookwithm2m_tags_5f958aa1" already exists


======================================================================
ERROR: test_m2m_create (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/tests/schema/tests.py", line 30, in tearDown
    self.delete_tables()
  File "/home/florian/sources/django.git/tests/schema/tests.py", line 36, in delete_tables
    table_names = connection.introspection.table_names(cursor)
  File "/home/florian/sources/django.git/django/db/backends/__init__.py", line 1245, in table_names
    return sorted(self.get_table_list(cursor))
  File "/home/florian/sources/django.git/django/db/backends/postgresql_psycopg2/introspection.py", line 39, in get_table_list
    AND pg_catalog.pg_table_is_visible(c.oid)""")
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
InternalError: current transaction is aborted, commands ignored until end of transaction block


======================================================================
ERROR: test_m2m_create (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/django/test/testcases.py", line 182, in __call__
    self._post_teardown()
  File "/home/florian/sources/django.git/django/test/testcases.py", line 765, in _post_teardown
    self._fixture_teardown()
  File "/home/florian/sources/django.git/django/test/testcases.py", line 786, in _fixture_teardown
    inhibit_post_migrate=self.available_apps is not None)
  File "/home/florian/sources/django.git/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/home/florian/sources/django.git/django/core/management/base.py", line 289, in execute
    output = self.handle(*args, **options)
  File "/home/florian/sources/django.git/django/core/management/base.py", line 419, in handle
    return self.handle_noargs(**options)
  File "/home/florian/sources/django.git/django/core/management/commands/flush.py", line 52, in handle_noargs
    allow_cascade=allow_cascade)
  File "/home/florian/sources/django.git/django/core/management/sql.py", line 113, in sql_flush
    tables = connection.introspection.django_table_names(only_existing=True)
  File "/home/florian/sources/django.git/django/db/backends/__init__.py", line 1274, in django_table_names
    existing_tables = self.table_names()
  File "/home/florian/sources/django.git/django/db/backends/__init__.py", line 1245, in table_names
    return sorted(self.get_table_list(cursor))
  File "/home/florian/sources/django.git/django/db/backends/postgresql_psycopg2/introspection.py", line 39, in get_table_list
    AND pg_catalog.pg_table_is_visible(c.oid)""")
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
InternalError: current transaction is aborted, commands ignored until end of transaction block


----------------------------------------------------------------------
Ran 2 tests in 0.245s

FAILED (errors=3)
Destroying test database for alias 'default' ('django_test')...
Destroying test database for alias 'other' (':memory:')...

Change History (4)

comment:1 by Andrew Godwin <andrew@…>, 11 years ago

Owner: set to Andrew Godwin <andrew@…>
Resolution: fixed
Status: newclosed

In 6ede1db331d59e9a89eaa65101629d0ff642f8fc:

Fixed #21151 -- Bad cleanup in schema M2M repoint test

comment:2 by Florian Apolloner, 11 years ago

Resolution: fixed
Status: closednew

Cleanup there is still fragile:

./runtests.py --settings=test_sqlite schema schema
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..s....s...........s....s....E....
======================================================================
ERROR: test_m2m_repoint (schema.tests.SchemaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/tests/schema/tests.py", line 296, in test_m2m_repoint
    new_field,
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/schema.py", line 116, in alter_field
    return self._alter_many_to_many(model, old_field, new_field, strict)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/schema.py", line 138, in _alter_many_to_many
    self.create_model(new_field.rel.through)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 232, in create_model
    self.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 94, in execute
    cursor.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/base.py", line 476, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: table schema_bookwithm2m_uniques already exists

----------------------------------------------------------------------
Ran 34 tests in 0.190s

FAILED (errors=1, skipped=4)

comment:3 by Florian Apolloner, 11 years ago

I also get failures in the migrations (again, just running migrations twice):

python3.2 ./runtests.py --settings=test_sqlite migrations migrations
Creating test database for alias 'default'...
Creating test database for alias 'other'...
..............................................................................E......EEEEEE.EEEE
======================================================================
ERROR: test_files_content (migrations.test_commands.MakeMigrationsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/tests/migrations/test_commands.py", line 114, in test_files_content
    call_command("makemigrations", "migrations", verbosity=0)
  File "/home/florian/sources/django.git/django/core/management/__init__.py", line 159, in call_command
    return klass.execute(*args, **defaults)
  File "/home/florian/sources/django.git/django/core/management/base.py", line 289, in execute
    output = self.handle(*args, **options)
  File "/home/florian/sources/django.git/django/core/management/commands/makemigrations.py", line 48, in handle
    loader.graph.project_state(),
  File "/home/florian/sources/django.git/django/utils/functional.py", line 49, in __get__
    res = instance.__dict__[self.func.__name__] = self.func(instance)
  File "/home/florian/sources/django.git/django/db/migrations/loader.py", line 123, in graph
    self.load_disk()
  File "/home/florian/sources/django.git/django/db/migrations/loader.py", line 78, in load_disk
    for name in os.listdir(directory):
OSError: [Errno 2] No such file or directory: '/home/florian/sources/django.git/tests/migrations/migrations'

======================================================================
ERROR: test_add_field (migrations.test_operations.OperationTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/base.py", line 476, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: table test_adfl_pony already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/florian/sources/django.git/tests/migrations/test_operations.py", line 97, in test_add_field
    project_state = self.set_up_test_model("test_adfl")
  File "/home/florian/sources/django.git/tests/migrations/test_operations.py", line 36, in set_up_test_model
    operation.database_forwards(app_label, editor, ProjectState(), project_state)
  File "/home/florian/sources/django.git/django/db/migrations/operations/models.py", line 24, in database_forwards
    schema_editor.create_model(model)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 232, in create_model
    self.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/backends/schema.py", line 94, in execute
    cursor.execute(sql, params)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/florian/sources/django.git/django/utils/six.py", line 490, in reraise
    raise value.with_traceback(tb)
  File "/home/florian/sources/django.git/django/db/utils.py", line 101, in inner
    return func(*args, **kwargs)
  File "/home/florian/sources/django.git/django/db/backends/sqlite3/base.py", line 476, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: table test_adfl_pony already exists
...

comment:4 by Andrew Godwin, 11 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top