﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16956	ContentTypes error in test with master/slave configuration	Petr Gorodechnyj <petr.gorodechnyj@…>	nobody	"Hello.
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:
{{{
DATABASES = {
    '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 :
    DATABASE_ROUTERS = ['path.to.MasterSlaveRouter']
}}}

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 manage.py test
}}}
is this stack trace:
{{{
Traceback (most recent call last):
  File ""manage.py"", line 15, in <module>
    execute_manager(settings)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 438, in execute_manager
    utility.execute()
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/base.py"", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/base.py"", line 220, in execute
    output = self.handle(*args, **options)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/commands/test.py"", line 37, in handle
    failures = test_runner.run_tests(test_labels)
  File ""/usr/local/lib/python2.7/site-packages/django/test/simple.py"", line 359, in run_tests
    old_config = self.setup_databases()
  File ""/usr/local/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 ""/usr/local/lib/python2.7/site-packages/django/db/backends/creation.py"", line 366, in create_test_db
    load_initial_data=False)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 166, in call_command
    return klass.execute(*args, **defaults)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/base.py"", line 220, in execute
    output = self.handle(*args, **options)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/base.py"", line 351, in handle
    return self.handle_noargs(**options)
  File ""/usr/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py"", 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/sql.py"", line 190, in emit_post_sync_signal
    interactive=interactive, db=db)
  File ""/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py"", line 172, in send
    response = receiver(signal=self, sender=sender, **named)
  File ""/usr/local/lib/python2.7/site-packages/django/contrib/contenttypes/management.py"", line 25, in update_contenttypes
    content_types.remove(ct)
ValueError: list.remove(x): x not in list
}}}"	Bug	closed	contrib.contenttypes	1.3	Normal	needsinfo	contenttypes test valueerror		Unreviewed	0	0	0	0	0	0
