Esempio n. 1
0
def main(
    test_runner="cms.test_utils.runners.NormalTestRunner",
    junit_output_dir=".",
    time_tests=False,
    verbosity=1,
    failfast=False,
    test_labels=None,
):
    if not test_labels:
        test_labels = ["cms"]
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            # Test with time zone support enabled when it's available
            use_tz = VERSION[:2] >= (1, 4)
            warnings.filterwarnings(
                "error", r"DateTimeField received a naive datetime", RuntimeWarning, r"django\.db\.models\.fields"
            )
            configure(
                TEST_RUNNER=test_runner,
                JUNIT_OUTPUT_DIR=junit_output_dir,
                TIME_TESTS=time_tests,
                ROOT_URLCONF="cms.test_utils.project.urls",
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
                USE_TZ=use_tz,
            )
            from django.conf import settings
            from django.test.utils import get_runner

            TestRunner = get_runner(settings)

            test_runner = TestRunner(verbosity=verbosity, interactive=False, failfast=failfast)
            failures = test_runner.run_tests(test_labels)
    sys.exit(failures)
Esempio n. 2
0
def main(db_url="sqlite://localhost/:memory:",
         test_runner='cms.test_utils.runners.NormalTestRunner',
         junit_output_dir='.',
         time_tests=False,
         verbosity=1,
         failfast=False,
         test_labels=None):
    if not test_labels:
        test_labels = ['cms']
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            use_tz = VERSION[:2] >= (1, 4)
            warnings.filterwarnings(
                'error', r"DateTimeField received a naive datetime",
                RuntimeWarning, r'django\.db\.models\.fields')
            configure(db_url=db_url,
                      TEST_RUNNER=test_runner,
                      JUNIT_OUTPUT_DIR=junit_output_dir,
                      TIME_TESTS=time_tests,
                      ROOT_URLCONF='cms.test_utils.project.urls',
                      STATIC_ROOT=STATIC_ROOT,
                      MEDIA_ROOT=MEDIA_ROOT,
                      USE_TZ=use_tz)
            from django.conf import settings
            from django.test.utils import get_runner
            TestRunner = get_runner(settings)

            test_runner = TestRunner(verbosity=verbosity,
                                     interactive=False,
                                     failfast=failfast)
            failures = test_runner.run_tests(test_labels)
    sys.exit(failures)
Esempio n. 3
0
    def test_extra_settings(self):
        from django.conf import settings

        with work_in(self.basedir):
            with captured_output() as (out, err):
                args = copy(DEFAULT_ARGS)
                with temp_dir() as STATIC_ROOT:
                    with temp_dir() as MEDIA_ROOT:
                        local_settings = _make_settings(args, self.application,
                                                        settings,
                                                        STATIC_ROOT, MEDIA_ROOT)
                        # Testing that cms_helper.py in custom project is loaded
                        self.assertEqual(local_settings.TIME_ZONE, 'Europe/Rome')

                        args['--extra-settings'] = 'cms_helper_extra.py'
                        local_settings = _make_settings(args, self.application,
                                                        settings,
                                                        STATIC_ROOT, MEDIA_ROOT)
                        # Testing that cms_helper.py in the command option is loaded
                        self.assertEqual(local_settings.TIME_ZONE, 'Europe/Paris')
                        # Existing application is kept
                        self.assertTrue('mptt' in local_settings.INSTALLED_APPS)
                        # New one is added
                        self.assertTrue('djangocms_admin_style' in local_settings.INSTALLED_APPS)
                        # Existing application is kept
                        self.assertTrue('django.core.context_processors.request' in local_settings.TEMPLATE_CONTEXT_PROCESSORS)
                        # New one is added
                        self.assertTrue('django.core.context_processors.debug' in local_settings.TEMPLATE_CONTEXT_PROCESSORS)
Esempio n. 4
0
def main(test_runner='cms.test_utils.runners.NormalTestRunner',
         junit_output_dir='.',
         time_tests=False,
         verbosity=1,
         failfast=False,
         test_labels=None):
    if not test_labels:
        test_labels = ['cms']
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(TEST_RUNNER=test_runner,
                      JUNIT_OUTPUT_DIR=junit_output_dir,
                      TIME_TESTS=time_tests,
                      ROOT_URLCONF='cms.test_utils.project.urls',
                      STATIC_ROOT=STATIC_ROOT,
                      MEDIA_ROOT=MEDIA_ROOT)
            from django.conf import settings
            from django.test.utils import get_runner
            TestRunner = get_runner(settings)

            test_runner = TestRunner(verbosity=verbosity,
                                     interactive=False,
                                     failfast=failfast)
            failures = test_runner.run_tests(test_labels)
    sys.exit(failures)
Esempio n. 5
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                os.environ.get('DATABASE_URL', 'sqlite://localhost/cmstestdb.sqlite'),
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import call_command
            call_command('shell')
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                'sqlite://localhost/cmstestdb.sqlite',
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import call_command
            os.chdir('cms')
            call_command('compilemessages', all=True)
Esempio n. 7
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                'sqlite://localhost/cmstestdb.sqlite',
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import call_command
            os.chdir('cms')
            call_command('compilemessages', all=True)
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                os.environ.get('DATABASE_URL',
                               'sqlite://localhost/cmstestdb.sqlite'),
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import call_command
            call_command('shell')
Esempio n. 9
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                'sqlite://localhost/cmstestdb.sqlite',
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import execute_from_command_line

            os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.test_utils.cli")
            execute_from_command_line(sys.argv)
Esempio n. 10
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                "sqlite://localhost/cmstestdb.sqlite",
                ROOT_URLCONF="cms.test_utils.project.urls",
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            from django.core.management import execute_from_command_line

            os.environ.setdefault("DJANGO_SETTINGS_MODULE", "cms.test_utils.cli")
            execute_from_command_line(sys.argv)
Esempio n. 11
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(ROOT_URLCONF='cms.test_utils.project.urls',
                      STATIC_ROOT=STATIC_ROOT,
                      MEDIA_ROOT=MEDIA_ROOT,
                      DATABASES={
                          'default': {
                              'ENGINE': 'django.db.backends.sqlite3',
                              'NAME': 'cmstestdb.sqlite',
                          }
                      })
            from django.core.management import call_command
            call_command('shell')
Esempio n. 12
0
def main(test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir='.',
         time_tests=False, verbosity=1, failfast=False, test_labels=None):
    if not test_labels:
        test_labels = ['cms']
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
                TIME_TESTS=time_tests, ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT)
            from django.conf import settings
            from django.test.utils import get_runner
            TestRunner = get_runner(settings)
        
            test_runner = TestRunner(verbosity=verbosity, interactive=False, failfast=failfast)
            failures = test_runner.run_tests(test_labels)
    sys.exit(failures)
Esempio n. 13
0
def main():
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
                DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.sqlite3',
                        'NAME': 'cmstestdb.sqlite',
                    }
                }
            )
            from django.core.management import call_command
            call_command('shell')
Esempio n. 14
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', default='8000')
    parser.add_argument('-b', '--bind', default='127.0.0.1')
    args = parser.parse_args()
    new_db = not os.path.exists('cmstestdb.sqlite')
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
                DATABASES = {
                    'default': {
                        'ENGINE': 'django.db.backends.sqlite3',
                        'NAME': 'cmstestdb.sqlite',
                    }
                }
            )
            from django.core.management import call_command
            call_command('syncdb', interactive=False, migrate_all=new_db)
            call_command('migrate', interactive=False, fake=new_db)
            from django.contrib.auth.models import User
            if not User.objects.filter(is_superuser=True).exists():
                usr = User()
                usr.username = '******'
                usr.email = '*****@*****.**'
                usr.set_password('admin')
                usr.is_superuser = True
                usr.is_staff = True
                usr.is_active = True
                usr.save()
                print
                print "A admin user (username: admin, password: admin) has been created."
                print
            from django.contrib.staticfiles.management.commands import runserver
            rs = runserver.Command()
            rs.stdout = sys.stdout
            rs.stderr = sys.stderr
            rs.use_ipv6 = False
            rs._raw_ipv6 = False
            rs.addr = args.bind
            rs.port = args.port
            rs.inner_run(addrport='%s:%s' % (args.bind, args.port),
               insecure_serving=True)
Esempio n. 15
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', default='8000')
    parser.add_argument('-b', '--bind', default='127.0.0.1')
    args = parser.parse_args()
    new_db = not os.path.exists('cmstestdb.sqlite')
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(
                "sqlite://localhost/cmstestdb.sqlite",
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            if os.environ.get("RUN_MAIN") != "true":
                from django.core.management import call_command
                call_command('syncdb', interactive=False, migrate_all=new_db)
                call_command('migrate', interactive=False, fake=new_db)
                from django.contrib.auth.models import User
                if not User.objects.filter(is_superuser=True).exists():
                    usr = User()
                    usr.username = '******'
                    usr.email = '*****@*****.**'
                    usr.set_password('admin')
                    usr.is_superuser = True
                    usr.is_staff = True
                    usr.is_active = True
                    usr.save()
                    print
                    print "A admin user (username: admin, password: admin) has been created."
                    print
            from django.contrib.staticfiles.management.commands import runserver
            rs = runserver.Command()
            rs.stdout = sys.stdout
            rs.stderr = sys.stderr
            rs.use_ipv6 = False
            rs._raw_ipv6 = False
            rs.addr = args.bind
            rs.port = args.port
            autoreload.main(
                rs.inner_run, (), {
                    'addrport': '%s:%s' % (args.bind, args.port),
                    'insecure_serving': True,
                    'use_threading': True
                })
Esempio n. 16
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', default='8000')
    parser.add_argument('-b', '--bind', default='127.0.0.1')
    parser.add_argument('-d', '--db', default='sqlite://localhost/cmstestdb.sqlite')
    parser.add_argument('-n', '--new_db', action='store_true')
    args = parser.parse_args()
    if args.db.startswith("sqlite"):
        new_db = not os.path.exists('cmstestdb.sqlite')
    else:
        new_db = (args.new_db == 1)
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(args.db,
                ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT,
                MEDIA_ROOT=MEDIA_ROOT,
            )
            if os.environ.get("RUN_MAIN") != "true":
                from django.core.management import call_command
                call_command('syncdb', interactive=False, migrate_all=new_db)
                call_command('migrate', interactive=False, fake=new_db)
                from django.contrib.auth.models import User
                if not User.objects.filter(is_superuser=True).exists():
                    usr = User()
                    usr.username = '******'
                    usr.email = '*****@*****.**'
                    usr.set_password('admin')
                    usr.is_superuser = True
                    usr.is_staff = True
                    usr.is_active = True
                    usr.save()
                    print('')
                    print("A admin user (username: admin, password: admin) has been created.")
                    print('')
            from django.contrib.staticfiles.management.commands import runserver
            rs = runserver.Command()
            rs.stdout = sys.stdout
            rs.stderr = sys.stderr
            rs.use_ipv6 = False
            rs._raw_ipv6 = False
            rs.addr = args.bind
            rs.port = args.port
            autoreload.main(rs.inner_run, (), {'addrport':'%s:%s' % (args.bind, args.port), 'insecure_serving':True, 'use_threading':True})
Esempio n. 17
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p', '--port', default='8000')
    parser.add_argument('-b', '--bind', default='127.0.0.1')
    args = parser.parse_args()
    new_db = not os.path.exists('cmstestdb.sqlite')
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            configure(ROOT_URLCONF='cms.test_utils.project.urls',
                      STATIC_ROOT=STATIC_ROOT,
                      MEDIA_ROOT=MEDIA_ROOT,
                      DATABASES={
                          'default': {
                              'ENGINE': 'django.db.backends.sqlite3',
                              'NAME': 'cmstestdb.sqlite',
                          }
                      })
            from django.core.management import call_command
            call_command('syncdb', interactive=False, migrate_all=new_db)
            call_command('migrate', interactive=False, fake=new_db)
            from django.contrib.auth.models import User
            if not User.objects.filter(is_superuser=True).exists():
                usr = User()
                usr.username = '******'
                usr.email = '*****@*****.**'
                usr.set_password('admin')
                usr.is_superuser = True
                usr.is_staff = True
                usr.is_active = True
                usr.save()
                print
                print "A admin user (username: admin, password: admin) has been created."
                print
            from django.contrib.staticfiles.management.commands import runserver
            rs = runserver.Command()
            rs.stdout = sys.stdout
            rs.stderr = sys.stderr
            rs.use_ipv6 = False
            rs._raw_ipv6 = False
            rs.addr = args.bind
            rs.port = args.port
            rs.inner_run(addrport='%s:%s' % (args.bind, args.port),
                         insecure_serving=True)
Esempio n. 18
0
def main(db_url="sqlite://localhost/:memory:", test_runner='cms.test_utils.runners.NormalTestRunner', junit_output_dir='.',
         time_tests=False, verbosity=1, failfast=False, test_labels=None):
    if not test_labels:
        test_labels = ['cms']
    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            use_tz = VERSION[:2] >= (1, 4)
            warnings.filterwarnings(
                'error', r"DateTimeField received a naive datetime",
                RuntimeWarning, r'django\.db\.models\.fields')
            configure(db_url=db_url, TEST_RUNNER=test_runner, JUNIT_OUTPUT_DIR=junit_output_dir,
                TIME_TESTS=time_tests, ROOT_URLCONF='cms.test_utils.project.urls',
                STATIC_ROOT=STATIC_ROOT, MEDIA_ROOT=MEDIA_ROOT, USE_TZ=use_tz)
            from django.conf import settings
            from django.test.utils import get_runner
            TestRunner = get_runner(settings)

            test_runner = TestRunner(verbosity=verbosity, interactive=False, failfast=failfast)
            failures = test_runner.run_tests(test_labels)
    sys.exit(failures)
Esempio n. 19
0
def main():
    args = docopt(__doc__, version=cms.__version__)

    if args['pyflakes']:
        return static_analysis.pyflakes()
    
    if args['authors']:
        return generate_authors()

    # configure django
    warnings.filterwarnings(
        'error', r"DateTimeField received a naive datetime",
        RuntimeWarning, r'django\.db\.models\.fields')

    default_name = ':memory:' if args['test'] else 'local.sqlite'

    db_url = os.environ.get("DATABASE_URL", "sqlite://localhost/%s" % default_name)
    migrate = args.get('--migrate', False)

    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            use_tz = VERSION[:2] >= (1, 4)

            configs = {
                'db_url': db_url,
                'ROOT_URLCONF': 'cms.test_utils.project.urls',
                'STATIC_ROOT': STATIC_ROOT,
                'MEDIA_ROOT': MEDIA_ROOT,
                'USE_TZ': use_tz,
                'SOUTH_TESTS_MIGRATE': migrate,
            }

            if args['test']:
                configs['SESSION_ENGINE'] = "django.contrib.sessions.backends.cache"

            # Command line option takes precedent over environment variable
            auth_user_model = args['--user']

            if not auth_user_model:
                auth_user_model = os.environ.get("AUTH_USER_MODEL", None)

            if auth_user_model:
                if VERSION[:2] < (1, 5):
                    print()
                    print("Custom user models are not supported before Django 1.5")
                    print()
                else:
                    configs['AUTH_USER_MODEL'] = auth_user_model

            configure(**configs)

            # run
            if args['test']:
                # make "Address already in use" errors less likely, see Django
                # docs for more details on this env variable.
                os.environ.setdefault(
                    'DJANGO_LIVE_TEST_SERVER_ADDRESS',
                    'localhost:8000-9000'
                )
                if args['--xvfb']:
                    import xvfbwrapper
                    context = xvfbwrapper.Xvfb(width=1280, height=720)
                else:
                    @contextlib.contextmanager
                    def null_context():
                        yield
                    context = null_context()

                with context:
                    if args['isolated']:
                        failures = isolated(args['<test-label>'], args['--parallel'])
                        print()
                        print("Failed tests")
                        print("============")
                        if failures:
                            for failure in failures:
                                print(" - %s" % failure)
                        else:
                            print(" None")
                        num_failures = len(failures)
                    elif args['timed']:
                        num_failures = timed(args['<test-label>'])
                    else:
                        num_failures = test(args['<test-label>'], args['--parallel'], args['--failfast'])
                    sys.exit(num_failures)
            elif args['server']:
                server(args['--bind'], args['--port'], migrate)
            elif args['shell']:
                shell()
            elif args['compilemessages']:
                compilemessages()
            elif args['makemessages']:
                compilemessages()
Esempio n. 20
0
def main():
    args = docopt(__doc__, version=cms.__version__)

    if args['pyflakes']:
        return static_analysis.pyflakes()

    if args['authors']:
        return generate_authors()

    # configure django
    warnings.filterwarnings('error',
                            r"DateTimeField received a naive datetime",
                            RuntimeWarning, r'django\.db\.models\.fields')

    default_name = ':memory:' if args['test'] else 'local.sqlite'

    db_url = os.environ.get("DATABASE_URL",
                            "sqlite://localhost/%s" % default_name)
    migrate = args.get('--migrate', False)

    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            use_tz = VERSION[:2] >= (1, 4)

            configs = {
                'db_url': db_url,
                'ROOT_URLCONF': 'cms.test_utils.project.urls',
                'STATIC_ROOT': STATIC_ROOT,
                'MEDIA_ROOT': MEDIA_ROOT,
                'USE_TZ': use_tz,
                'SOUTH_TESTS_MIGRATE': migrate,
            }

            if args['test']:
                configs[
                    'SESSION_ENGINE'] = "django.contrib.sessions.backends.cache"

            # Command line option takes precedent over environment variable
            auth_user_model = args['--user']

            if not auth_user_model:
                auth_user_model = os.environ.get("AUTH_USER_MODEL", None)

            if auth_user_model:
                if VERSION[:2] < (1, 5):
                    print()
                    print(
                        "Custom user models are not supported before Django 1.5"
                    )
                    print()
                else:
                    configs['AUTH_USER_MODEL'] = auth_user_model

            configure(**configs)

            # run
            if args['test']:
                # make "Address already in use" errors less likely, see Django
                # docs for more details on this env variable.
                os.environ.setdefault('DJANGO_LIVE_TEST_SERVER_ADDRESS',
                                      'localhost:8000-9000')
                if args['--xvfb']:
                    import xvfbwrapper
                    context = xvfbwrapper.Xvfb(width=1280, height=720)
                else:

                    @contextlib.contextmanager
                    def null_context():
                        yield

                    context = null_context()

                with context:
                    if args['isolated']:
                        failures = isolated(args['<test-label>'],
                                            args['--parallel'])
                        print()
                        print("Failed tests")
                        print("============")
                        if failures:
                            for failure in failures:
                                print(" - %s" % failure)
                        else:
                            print(" None")
                        num_failures = len(failures)
                    elif args['timed']:
                        num_failures = timed(args['<test-label>'])
                    else:
                        num_failures = test(args['<test-label>'],
                                            args['--parallel'],
                                            args['--failfast'])
                    sys.exit(num_failures)
            elif args['server']:
                server(args['--bind'], args['--port'],
                       args.get('--migrate', True))
            elif args['shell']:
                shell()
            elif args['compilemessages']:
                compilemessages()
            elif args['makemessages']:
                makemessages()
            elif args['makemigrations']:
                makemigrations()
Esempio n. 21
0
def main():
    args = docopt(__doc__, version=cms.__version__)

    if args["pyflakes"]:
        return static_analysis.pyflakes()

    if args["authors"]:
        return generate_authors()

    # configure django
    warnings.filterwarnings(
        "error", r"DateTimeField received a naive datetime", RuntimeWarning, r"django\.db\.models\.fields"
    )

    default_name = ":memory:" if args["test"] else "local.sqlite"

    db_url = os.environ.get("DATABASE_URL", "sqlite://localhost/%s" % default_name)
    migrate = args.get("--migrate", False)

    with temp_dir() as STATIC_ROOT:
        with temp_dir() as MEDIA_ROOT:
            use_tz = VERSION[:2] >= (1, 4)

            configs = {
                "db_url": db_url,
                "ROOT_URLCONF": "cms.test_utils.project.urls",
                "STATIC_ROOT": STATIC_ROOT,
                "MEDIA_ROOT": MEDIA_ROOT,
                "USE_TZ": use_tz,
                "SOUTH_TESTS_MIGRATE": migrate,
            }

            if args["test"]:
                configs["SESSION_ENGINE"] = "django.contrib.sessions.backends.cache"

            # Command line option takes precedent over environment variable
            auth_user_model = args["--user"]

            if not auth_user_model:
                auth_user_model = os.environ.get("AUTH_USER_MODEL", None)

            if auth_user_model:
                if VERSION[:2] < (1, 5):
                    print()
                    print("Custom user models are not supported before Django 1.5")
                    print()
                else:
                    configs["AUTH_USER_MODEL"] = auth_user_model

            configure(**configs)

            # run
            if args["test"]:
                # make "Address already in use" errors less likely, see Django
                # docs for more details on this env variable.
                os.environ.setdefault("DJANGO_LIVE_TEST_SERVER_ADDRESS", "localhost:8000-9000")
                if args["--xvfb"]:
                    import xvfbwrapper

                    context = xvfbwrapper.Xvfb(width=1280, height=720)
                else:

                    @contextlib.contextmanager
                    def null_context():
                        yield

                    context = null_context()

                with context:
                    if args["isolated"]:
                        failures = isolated(args["<test-label>"], args["--parallel"])
                        print()
                        print("Failed tests")
                        print("============")
                        if failures:
                            for failure in failures:
                                print(" - %s" % failure)
                        else:
                            print(" None")
                        num_failures = len(failures)
                    elif args["timed"]:
                        num_failures = timed(args["<test-label>"])
                    else:
                        num_failures = test(args["<test-label>"], args["--parallel"], args["--failfast"])
                    sys.exit(num_failures)
            elif args["server"]:
                server(args["--bind"], args["--port"], args.get("--migrate", True))
            elif args["shell"]:
                shell()
            elif args["compilemessages"]:
                compilemessages()
            elif args["makemessages"]:
                makemessages()
            elif args["makemigrations"]:
                makemigrations()