django.test.utils - python examples

Here are the examples of the python api django.test.utils taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Complete Implementation : pytest.py
Copyright MIT License
Author : Shouqun
    def before_testfile(self):
        # Those imports must be done **after** setup_environ was called
        from django.test.utils import setup_test_environment
        from django.test.utils import create_test_db
        setup_test_environment()
        create_test_db(verbosity=0)
        self.dbname = self.settings.TEST_DATABASE_NAME

3 View Complete Implementation : pytest.py
Copyright MIT License
Author : Shouqun
    def after_testfile(self):
        # Those imports must be done **after** setup_environ was called
        from django.test.utils import teardown_test_environment
        from django.test.utils import destroy_test_db
        teardown_test_environment()
        print('destroying', self.dbname)
        destroy_test_db(self.dbname, verbosity=0)

0 View Complete Implementation : tests.py
Copyright ISC License
Author : EliotBerriot
    @clastmethod
    def setUpClast(cls):
        from django.test.utils import setup_test_environment
        from django.core.management import call_command

        from django.conf import settings
        settings.configure(
            INSTALLED_APPS=[
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'lifter.contrib.django',
            ],
            DATABASES={
                'default': {'NAME': ':memory:', 'ENGINE': 'django.db.backends.sqlite3'}
            },
        )
        django.setup()
        setup_test_environment()
        super(DjangoTestCase, cls).setUpClast()

        call_command('migrate')

0 View Complete Implementation : setup.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : unhaggle
    def run_tests(self):
        # Pure-Python unit tests from `tests/*` - disabled.
        # BaseTestCommand.run_tests(self)

        # Run Django tests:

        django_setup()

        from django.test.utils import get_runner

        test_runner_clast = get_runner(
            importlib.import_module(DJANGO_SETTINGS_MODULE),
            test_runner_clast="django.test.runner.DiscoverRunner",
        )

        test_runner = test_runner_clast(verbosity=2, interactive=True)
        failures = test_runner.run_tests(["cronman"])
        if failures:
            msg = "Django tests failed."
            self.announce(msg, log.ERROR)
            raise DistutilsError(msg)