Exemple #1
0
 def test_run_checks_raises(self):
     """
     Teardown functions are run when run_checks() raises SystemCheckError.
     """
     with mock.patch(
             "django.test.runner.DiscoverRunner.setup_test_environment"
     ), mock.patch(
             "django.test.runner.DiscoverRunner.setup_databases"
     ), mock.patch(
             "django.test.runner.DiscoverRunner.build_suite"
     ), mock.patch(
             "django.test.runner.DiscoverRunner.run_checks",
             side_effect=SystemCheckError
     ), mock.patch(
             "django.test.runner.DiscoverRunner.teardown_databases"
     ) as teardown_databases, mock.patch(
             "django.test.runner.DiscoverRunner.teardown_test_environment"
     ) as teardown_test_environment:
         runner = DiscoverRunner(verbosity=0, interactive=False)
         with self.assertRaises(SystemCheckError):
             runner.run_tests([
                 "test_runner_apps.sample.tests_sample.TestDjangoTestCase"
             ])
         self.assertTrue(teardown_databases.called)
         self.assertTrue(teardown_test_environment.called)
Exemple #2
0
 def test_run_checks_passes_and_teardown_raises(self):
     """
     Exceptions on teardown are surfaced if no exceptions happen during
     run_checks().
     """
     with mock.patch(
         "django.test.runner.DiscoverRunner.setup_test_environment"
     ), mock.patch("django.test.runner.DiscoverRunner.setup_databases"), mock.patch(
         "django.test.runner.DiscoverRunner.build_suite"
     ), mock.patch(
         "django.test.runner.DiscoverRunner.run_checks"
     ), mock.patch(
         "django.test.runner.DiscoverRunner.teardown_databases",
         side_effect=ValueError,
     ) as teardown_databases, mock.patch(
         "django.test.runner.DiscoverRunner.teardown_test_environment"
     ) as teardown_test_environment:
         runner = DiscoverRunner(verbosity=0, interactive=False)
         with self.assertRaises(ValueError):
             # Suppress the output when running TestDjangoTestCase.
             with mock.patch("sys.stderr"):
                 runner.run_tests(
                     ["test_runner_apps.sample.tests_sample.TestDjangoTestCase"]
                 )
         self.assertTrue(teardown_databases.called)
         self.assertFalse(teardown_test_environment.called)
Exemple #3
0
 def test_run_checks_raises(self):
     """
     Teardown functions are run when run_checks() raises SystemCheckError.
     """
     with mock.patch('django.test.runner.DiscoverRunner.setup_test_environment'), \
             mock.patch('django.test.runner.DiscoverRunner.setup_databases'), \
             mock.patch('django.test.runner.DiscoverRunner.build_suite'), \
             mock.patch('django.test.runner.DiscoverRunner.run_checks', side_effect=SystemCheckError), \
             mock.patch('django.test.runner.DiscoverRunner.teardown_databases') as teardown_databases, \
             mock.patch('django.test.runner.DiscoverRunner.teardown_test_environment') as teardown_test_environment:
         runner = DiscoverRunner(verbosity=0, interactive=False)
         with self.assertRaises(SystemCheckError):
             runner.run_tests(['test_runner_apps.sample.tests_sample.TestDjangoTestCase'])
         self.assertTrue(teardown_databases.called)
         self.assertTrue(teardown_test_environment.called)
def run_tests():
    import django
    from django.conf import settings, global_settings
    settings.configure(
        # Minimal django settings
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'TEST_NAME': ':memory:',
            },
        },
        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES,
        INSTALLED_APPS=['etcd_settings'],
        DJES_DEV_PARAMS=None,
        DJES_REQUEST_GETTER=None,
        DJES_ENV='dev',
        DJES_ETCD_DETAILS=None,
        DJES_WSGI_FILE=None
        # DJES_ETCD_DETAILS=dict(host='localhost', port=4000, protocol='http',
        #                        prefix='/config/my-django-app')
    )
    if hasattr(django, 'setup'):
        django.setup()

    try:
        from django.test.runner import DiscoverRunner as Runner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner as Runner

    test_runner = Runner(verbosity=1)
    return test_runner.run_tests(['tests'])
Exemple #5
0
def run_tests():
    import django
    from django.conf import global_settings
    from django.conf import settings
    settings.configure(
        INSTALLED_APPS=[
            'corsheaders',
        ],
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'TEST_NAME': ':memory:',
            },
        },
        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
            'corsheaders.middleware.CorsMiddleware',),
    )
    if hasattr(django, 'setup'):
        django.setup()

    try:
        from django.test.runner import DiscoverRunner as Runner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner as Runner

    test_runner = Runner(verbosity=1)
    return test_runner.run_tests(['corsheaders'])
Exemple #6
0
def main():
    """
    Standalone django model test with a 'memory-only-django-installation'.
    You can play with a django model without a complete django app installation.
    http://www.djangosnippets.org/snippets/1044/
    """
    settings.configure(
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.sessions',
            'django.contrib.contenttypes',
            'upyun',
        ),
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': ':memory:',
            }
        },
        ROOT_URLCONF='beproud.django.authutils.tests.test_urls',
        DEFAULT_FILE_STORAGE='django_upyun.UpYunStorage',
        UPYUN_USERNAME=os.getenv('UPYUN_USERNAME'),
        UPYUN_PASSWORD=os.getenv('UPYUN_PASSWORD'),
        UPYUN_BUCKET=os.getenv('UPYUN_BUCKET'),
        MEDIA_URL="http://%s.b0.upaiyun.com/media/" % os.getenv('UPYUN_BUCKET'),
        STATIC_URL="http://%s.b0.upaiyun.com/static/" % os.getenv('UPYUN_BUCKET')
    )
    django.setup()
    from django.test.runner import DiscoverRunner
    test_runner = DiscoverRunner(verbosity=1)

    failures = test_runner.run_tests(['upyun'])
    sys.exit(failures)
Exemple #7
0
    def _tests(self):

        settings.configure(
            DEBUG=True,
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                    'USER': '',
                    'PASSWORD': '',
                    'HOST': '',
                    'PORT': '',
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
            MIDDLEWARE_CLASSES=self.MIDDLEWARE_CLASSES,
            ROOT_URLCONF='helpdesk.tests.urls',
            STATIC_URL='/static/',
            TEMPLATES=self.TEMPLATES
        )

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner(verbosity=1)
        django.setup()

        failures = test_runner.run_tests(self.apps)
        if failures:
            sys.exit(failures)
Exemple #8
0
def run_tests():
    import django
    from django.conf import global_settings
    from django.conf import settings
    settings.configure(
        INSTALLED_APPS=[
            'corsheaders',
        ],
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'TEST_NAME': ':memory:',
            },
        },
        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES +
        ('corsheaders.middleware.CorsMiddleware', ),
    )
    if hasattr(django, 'setup'):
        django.setup()

    try:
        from django.test.runner import DiscoverRunner as Runner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner as Runner

    test_runner = Runner(verbosity=1)
    return test_runner.run_tests(['corsheaders'])
Exemple #9
0
def run_tests():
    sys.stdout.write(
        "\nRunning spirit test suite, using settings %(settings)r\n\n" %
        {"settings": os.environ['DJANGO_SETTINGS_MODULE']})
    test_runner = DiscoverRunner()
    failures = test_runner.run_tests([])
    sys.exit(failures)
Exemple #10
0
def main():
    settings.configure(
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'nicedit',
        ),
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
            },
        },
        MIDDLEWARE_CLASSES=(
            'django.middleware.common.CommonMiddleware',
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware'),
        ROOT_URLCONF='nicedit.urls',
        MEDIA_ROOT=os.path.join(os.path.dirname(__file__), 'app_media'),
        SITE_ID=1,
    )

    setup()

    from django.test.runner import DiscoverRunner

    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests([
        'nicedit',
    ])
    if failures:
        sys.exit(failures)
Exemple #11
0
    def _tests(self):

        settings.configure(DEBUG=True,
                           DATABASES={
                               'default': {
                                   'ENGINE':
                                   'django.db.backends.sqlite3',
                                   'NAME':
                                   os.path.join(self.DIRNAME, 'database.db'),
                                   'USER':
                                   '',
                                   'PASSWORD':
                                   '',
                                   'HOST':
                                   '',
                                   'PORT':
                                   '',
                               }
                           },
                           INSTALLED_APPS=self.INSTALLED_APPS,
                           MIDDLEWARE=self.MIDDLEWARE,
                           ROOT_URLCONF='helpdesk.tests.urls',
                           STATIC_URL='/static/',
                           LOGIN_URL='/helpdesk/login/',
                           TEMPLATES=self.TEMPLATES,
                           SITE_ID=1)

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner(verbosity=1)
        django.setup()

        failures = test_runner.run_tests(self.tests)
        if failures:
            sys.exit(failures)
Exemple #12
0
    def _tests(self):

        settings.configure(
            DEBUG=True,
            TIME_ZONE='UTC',
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                    'USER': '',
                    'PASSWORD': '',
                    'HOST': '',
                    'PORT': '',
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS,
            MIDDLEWARE=self.MIDDLEWARE,
            ROOT_URLCONF='helpdesk.tests.urls',
            STATIC_URL='/static/',
            LOGIN_URL='/helpdesk/login/',
            TEMPLATES=self.TEMPLATES,
            SITE_ID=1,
            ## The following settings disable teams
            HELPDESK_TEAMS_MODEL = 'auth.User',
            HELPDESK_TEAMS_MIGRATION_DEPENDENCIES = [],
            HELPDESK_KBITEM_TEAM_GETTER = lambda _: None
        )

        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner(verbosity=1)
        django.setup()

        failures = test_runner.run_tests(self.tests)
        if failures:
            sys.exit(failures)
Exemple #13
0
def run_tests():
    sys.stdout.write(
        "\nRunning spirit test suite, using settings %(settings)r\n\n" %
        {"settings": os.environ['DJANGO_SETTINGS_MODULE']})
    test_runner = DiscoverRunner()
    failures = test_runner.run_tests([])
    sys.exit(failures)
Exemple #14
0
def get_suite(labels=default_labels):
    runner = DiscoverRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    return TestSuite()
Exemple #15
0
    def run_tests(self):
        """
        Fire up the Django test suite
        """
        settings.configure(
            DEBUG = True,
            DATABASES = {
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                    'USER': '',
                    'PASSWORD': '',
                    'HOST': '',
                    'PORT': '',
                }
            },
            LOGGING = {
                'version': 1,
                'formatters': {'simple': {'format': '%(levelname)s %(asctime)s %(name)s %(message)s'}},
                'handlers': {'console': {'class': 'logging.StreamHandler', 'formatter': 'simple'}},
                'loggers': {'screamshot': {'handlers': ['console'], 'level': 'DEBUG'}}
            },
            INSTALLED_APPS = self.INSTALLED_APPS + self.apps
        )

        django.setup()

        test_runner = DiscoverRunner(verbosity=1)

        failures = test_runner.run_tests(self.apps)
        if failures: # pragma: no cover
            sys.exit(failures)
Exemple #16
0
def runner(options):
    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    sys.path.append(BASE_DIR)

    vhost = {
        'host': options.host,
        'port': options.port,
        'name': options.name,
        'username': options.username,
        'password': options.password,
        'secure': options.secure,
    }
    _vhost = VirtualHost(**vhost)
    settings.configure(
        DEBUG=True,
        DATABASES={
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'NAME': 'local',
            }
        },
        ROOT_URLCONF='carrot.urls',
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.admin',
            'django.contrib.staticfiles',
            'carrot',
        ),
        CARROT={
            'default_broker': str(_vhost),
        },
        TEMPLATES=[
            {
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'DIRS': [os.path.join(BASE_DIR, 'templates')],
                'APP_DIRS': True,
                'OPTIONS': {
                    'context_processors': [
                        'django.template.context_processors.debug',
                        'django.template.context_processors.request',
                        'django.contrib.auth.context_processors.auth',
                        'django.contrib.messages.context_processors.messages',
                    ],
                },
            },
        ],
        STATIC_URL='/static/',
    )
    django.setup()

    from django.test.runner import DiscoverRunner

    test_runner = DiscoverRunner(verbosity=0, )

    failures = test_runner.run_tests(['carrot'])
    if failures:
        sys.exit(failures)
Exemple #17
0
def runtests(options={}):
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    django.setup()
    setup_test_environment()
    test_runner = DiscoverRunner(**options)
    failures = test_runner.run_tests(['django_elect'])
    sys.exit(failures)
Exemple #18
0
def main():
    settings.configure(
        INSTALLED_APPS=[
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'force_error'
        ],
        DATABASES={'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': ':memory:'
        }}

    )
    django.setup()

    test_runner = DiscoverRunner(verbosity=1)
    test_runner.run_tests(['force_error'])
Exemple #19
0
def runtests(*test_args, **kwargs):
    if not test_args:
        test_args = ['djangobb_forum']
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    test_runner = DiscoverRunner(verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False), failfast=kwargs.get('failfast'))
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
Exemple #20
0
def runtests(*args):
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    testrunner = DjangoTestRunner()
    if not args:
        args = None
    failures = testrunner.run_tests(args)
    sys.exit(failures)
Exemple #21
0
def get_suite(labels=default_labels):
    from django.test.runner import DiscoverRunner
    runner = DiscoverRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)
    # In case this is called from setuptools, return a test suite
    return TestSuite()
Exemple #22
0
def runtests(*test_args):
    from django.test.runner import DiscoverRunner

    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    test_runner = DiscoverRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
Exemple #23
0
 def test_run_checks_raises_and_teardown_raises(self):
     """
     SystemCheckError is surfaced when run_checks() raises SystemCheckError
     and teardown databases() raises ValueError.
     """
     with mock.patch('django.test.runner.DiscoverRunner.setup_test_environment'), \
             mock.patch('django.test.runner.DiscoverRunner.setup_databases'), \
             mock.patch('django.test.runner.DiscoverRunner.build_suite'), \
             mock.patch('django.test.runner.DiscoverRunner.run_checks', side_effect=SystemCheckError), \
             mock.patch('django.test.runner.DiscoverRunner.teardown_databases', side_effect=ValueError) \
             as teardown_databases, \
             mock.patch('django.test.runner.DiscoverRunner.teardown_test_environment') as teardown_test_environment:
         runner = DiscoverRunner(verbosity=0, interactive=False)
         with self.assertRaises(SystemCheckError):
             runner.run_tests(['test_runner_apps.sample.tests_sample.TestDjangoTestCase'])
         self.assertTrue(teardown_databases.called)
         self.assertFalse(teardown_test_environment.called)
Exemple #24
0
def runtests(options={}):
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    django.setup()
    setup_test_environment()
    test_runner = DiscoverRunner(**options)
    failures = test_runner.run_tests(['django_elect'])
    sys.exit(failures)
Exemple #25
0
def run_tests():
    """Run the test suite."""
    import django
    from django.test.runner import DiscoverRunner
    django.setup()
    test_runner = DiscoverRunner(verbosity=2, interactive=False)
    failures = test_runner.run_tests(['.'])
    sys.exit(bool(failures))
def runtests(*test_args):
    from django.test.runner import DiscoverRunner

    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    test_runner = DiscoverRunner(verbosity=1, interactive=True)
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
def runtests(*test_args, **kwargs):
    if not test_args:
        test_args = ['countries_field']

    django.setup()
    test_runner = DiscoverRunner(**kwargs)

    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
def runtests(*test_args):
    if not test_args:
        test_args = ["fixture_generator.tests"]
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    setup()
    runner = DiscoverRunner(verbosity=2, interactive=True, failfast=False)
    failures = runner.run_tests(test_args)
    sys.exit(failures)
Exemple #29
0
def run_tests(*test_args):

    # Run tests
    test_runner = DiscoverRunner(verbosity=1)

    failures = test_runner.run_tests(test_args)

    if failures:
        sys.exit(failures)
Exemple #30
0
def runtests():
    if not settings.configured:
        from staticinline.tests.testapp import settings as TEST_SETTINGS
        settings.configure(**TEST_SETTINGS.__dict__)
    setup()
    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['staticinline'])
    if failures:
        sys.exit(failures)
def runtests():
    setup_test_environment()

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    runner = DiscoverRunner(verbosity=1, interactive=True, failfast=False)
    failures = runner.run_tests(())
    sys.exit(failures)
Exemple #32
0
def runtests():
    setup_test_environment()

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    runner = DiscoverRunner(verbosity=1, interactive=True, failfast=False)
    failures = runner.run_tests(())
    sys.exit(failures)
def run_tests():
    # Modify path
    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    # Run tests
    test_runner = DiscoverRunner(verbosity=2)
    failures = test_runner.run_tests(['tests'])
    sys.exit(failures)
Exemple #34
0
def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tests.settings')
    print(os.getenv('DJANGO_SETTINGS_MODULE'))
    import django
    django.setup()
    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['tests'])
    if failures:
        sys.exit(failures)
Exemple #35
0
def runtests(*test_args, **kwargs):
    if not test_args:
        test_args = ['countries_field']

    django.setup()
    test_runner = DiscoverRunner(**kwargs)

    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
def runtests():
    if not settings.configured:
        settings.configure(**DEFAULT_SETTINGS)

    django.setup()

    test_runner = DiscoverRunner(verbosity=1, interactive=True, failfast=False)
    failures = test_runner.run_tests(['tests'])
    sys.exit(bool(failures))
def run_tests():
    # Modify path
    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    # Run tests
    test_runner = DiscoverRunner(verbosity=2)
    failures = test_runner.run_tests(['tests'])
    sys.exit(failures)
Exemple #38
0
def runtests(*test_args):
    # Setup settings
    if not settings.configured:
        settings.configure(**test_settings.__dict__)
    setup()
    test_runner = TestRunner(verbosity=1)
    failures = test_runner.run_tests(['dpaste'])
    if failures:
        sys.exit(failures)
def runtests(*test_args, **kwargs):
    django.setup()

    if not test_args:
        test_args = ['private_messages']

    test_runner = Runner(verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False),
                         failfast=kwargs.get('failfast'))
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
Exemple #40
0
def runtests(*test_args, **kwargs):
    django.setup()

    if not test_args:
        test_args = ['pybb']

    test_runner = Runner(verbosity=kwargs.get('verbosity', 1), interactive=kwargs.get('interactive', False),
                         failfast=kwargs.get('failfast'))
    failures = test_runner.run_tests(test_args)
    sys.exit(failures)
Exemple #41
0
def runtests(*test_args):
    # Setup settings
    if not settings.configured:
        from memcache_status.tests.testapp import settings as TEST_SETTINGS
        settings.configure(**TEST_SETTINGS.__dict__)
    setup()
    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['memcache_status'])
    if failures:
        sys.exit(failures)
Exemple #42
0
def runtests():
    load_dotenv(find_dotenv())
    django.setup()

    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests([])
    if failures:
        sys.exit(failures)

    sys.exit(bool(failures))
    def run_tests():
        print("Running tests against %s database." % db)

        #from django.test.simple import DjangoTestSuiteRunner
        #test_runner = DjangoTestSuiteRunner(verbosity=1, failfast=False)
        from django.test.runner import DiscoverRunner
        test_runner = DiscoverRunner(verbosity=1, failfast=False)
        failures = test_runner.run_tests(['django_database_constraints', ])
        if failures: #pragma no cover
            sys.exit(failures)
def runtests(*test_args):
    # Setup settings
    if not settings.configured:
        from django_generic_flatblocks.tests.testapp import settings as TEST_SETTINGS
        settings.configure(**TEST_SETTINGS.__dict__)
    setup()
    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['django_generic_flatblocks'])
    if failures:
        sys.exit(failures)
def runtests():
    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    django.setup()

    runner = DiscoverRunner(verbosity=1, interactive=True,
                            failfast=bool(os.environ.get('FAILFAST')))
    failures = runner.run_tests(())
    sys.exit(failures)
Exemple #46
0
 def test_run_checks_passes_and_teardown_raises(self):
     """
     Exceptions on teardown are surfaced if no exceptions happen during
     run_checks().
     """
     with mock.patch('django.test.runner.DiscoverRunner.setup_test_environment'), \
             mock.patch('django.test.runner.DiscoverRunner.setup_databases'), \
             mock.patch('django.test.runner.DiscoverRunner.build_suite'), \
             mock.patch('django.test.runner.DiscoverRunner.run_checks'), \
             mock.patch('django.test.runner.DiscoverRunner.teardown_databases', side_effect=ValueError) \
             as teardown_databases, \
             mock.patch('django.test.runner.DiscoverRunner.teardown_test_environment') as teardown_test_environment:
         runner = DiscoverRunner(verbosity=0, interactive=False)
         with self.assertRaises(ValueError):
             # Suppress the output when running TestDjangoTestCase.
             with mock.patch('sys.stderr'):
                 runner.run_tests(['test_runner_apps.sample.tests_sample.TestDjangoTestCase'])
         self.assertTrue(teardown_databases.called)
         self.assertFalse(teardown_test_environment.called)
def runtests(options=None):
    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
    django.setup()

    verbosity = options.verbosity if options else 1
    failfast = options.failfast if options else False
    test_runner = DiscoverRunner(verbosity=verbosity, failfast=failfast)

    labels = options.labels if options else []
    failures = test_runner.run_tests(labels or ['newsletter'])
    sys.exit(failures)
def run_tests(*test_args):
    if not test_args:
        test_args = ['cla_common']

    # Run tests
    test_runner = DiscoverRunner(verbosity=1)

    failures = test_runner.run_tests(test_args)

    if failures:
        sys.exit(failures)
def main():
    if django.VERSION >= (1, 7):
        django.setup()
    if not os.path.exists(os.path.join(here, 'testapp/migrations/0001_initial.py')):
        call_command('makemigrations')
    from django.contrib import admin
    admin.autodiscover()
    from django.test.runner import DiscoverRunner
    runner = DiscoverRunner(failfast=True, verbosity=int(os.environ.get('DJANGO_DEBUG', 1)))
    failures = runner.run_tests(['testapp'], interactive=True)
    sys.exit(failures)
Exemple #50
0
def runtests():
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tests.settings")

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)

    django.setup()

    runner = DiscoverRunner(verbosity=1, interactive=True, failfast=False)
    failures = runner.run_tests(())
    sys.exit(failures)
def runtests(*test_args):
    # Setup settings
    if not settings.configured:
        settings.configure(**SETTINGS)

    setup()

    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['attachments'])
    if failures:
        sys.exit(failures)
Exemple #52
0
def main():
    if django.VERSION >= (1, 7):
        django.setup()
    if sys.argv[-1] == 'shell':
        call_command('shell')
        sys.exit(0)
    else:
        from django.test.runner import DiscoverRunner
        runner = DiscoverRunner(failfast=True, verbosity=int(os.environ.get('DJANGO_DEBUG', 1)))
        failures = runner.run_tests(['dbbackup'], interactive=True)
        sys.exit(failures)
def runtests(*test_args):
    # Setup settings
    if not settings.configured:
        settings.configure(**SETTINGS)

    setup()

    test_runner = DiscoverRunner(verbosity=1)
    failures = test_runner.run_tests(['wakawaka'])
    if failures:
        sys.exit(failures)