Opened 7 years ago

Closed 7 years ago

#16956 closed Bug (needsinfo)

ContentTypes error in test with master/slave configuration

Reported by: Petr Gorodechnyj <petr.gorodechnyj@…> Owned by: nobody
Component: contrib.contenttypes Version: 1.3
Severity: Normal Keywords: contenttypes test valueerror
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I get strange "ValueError: list.remove(x): x not in list" when I try to test my project. This happens only with master/slave configuration. If I use single 'default' database everything works ok.
Database configuration:

    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'dbname',
        'USER': 'gorodechnyj',
        'PASSWORD': 'pass',
        'HOST': 'host',
        'PORT': '5432',
        'TEST_CHARSET': 'UTF-8',
    'slave': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'dbname',
        'USER': 'gorodechnyj',
        'PASSWORD': 'pass',
        'HOST': 'host',
        'PORT': '5432',
        'TEST_CHARSET': 'UTF-8',
        'TEST_MIRROR': 'default'
if len(DATABASES) > 1 :

Router configuration:

import random

class MasterSlaveRouter(object):
    ''' A router that sets up a simple master/slave configuration '''

    def db_for_read(self, model, **hints):
        return random.choice(['default', 'slave'])

    def db_for_write(self, model, **hints):
        "Point all write operations to the master"
        return 'default'

    def allow_relation(self, obj1, obj2, **hints):
        "Allow any relation between two objects"
        return True

    def allow_syncdb(self, db, model):
        if db == 'default':
            return True
        return False

What I got in case of

python test

is this stack trace:

Traceback (most recent call last):
  File "", line 15, in <module>
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 438, in execute_manager
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 379, in execute
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/", line 37, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.7/site-packages/django/test/", line 359, in run_tests
    old_config = self.setup_databases()
  File "/usr/local/lib/python2.7/site-packages/django/test/", line 296, in setup_databases
    test_db_name = connection.creation.create_test_db(self.verbosity, autoclobber=not self.interactive)
  File "/usr/local/lib/python2.7/site-packages/django/db/backends/", line 366, in create_test_db
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 166, in call_command
    return klass.execute(*args, **defaults)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 220, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 351, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/", line 109, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/usr/local/lib/python2.7/site-packages/django/core/management/", line 190, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/usr/local/lib/python2.7/site-packages/django/dispatch/", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/lib/python2.7/site-packages/django/contrib/contenttypes/", line 25, in update_contenttypes
ValueError: list.remove(x): x not in list

Change History (1)

comment:1 Changed 7 years ago by Aymeric Augustin

Resolution: needsinfo
Status: newclosed

This code was rewritten in r16739. Could you check if the problem still occurs with a recent svn checkout? Please reopen the ticket if it does.

Note: See TracTickets for help on using tickets.
Back to Top