예제 #1
0
def get_suite(labels=default_labels):
    from awl.waelsteng import WRunner
    runner = WRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    # in case this is called from setup tools, return a test suite
    return TestSuite()
예제 #2
0
def get_suite(labels=default_labels):
    from awl.waelsteng import WRunner
    runner = WRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    # in case this is called from setup tools, return a test suite
    return TestSuite()
def get_suite(labels=default_labels):
    #-- Configure Django
    BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
        'bseditor'))

    settings.configure(
        BASE_DIR=BASE_DIR,
        DEBUG=True,
        DATABASES={
            'default':{
                'ENGINE':'django.db.backends.sqlite3',
            }
        },
        ROOT_URLCONF='bseditor.tests.urls',
        MIDDLEWARE_CLASSES = (
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'django.middleware.common.CommonMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.admin',
            'django.contrib.staticfiles',
            'awl',
            'bseditor',
            'bseditor.tests',
        ),
        TEMPLATE_DIRS = (
            os.path.abspath(os.path.join(BASE_DIR, 'bseditor/templates')),
        ),
        STATIC_URL='/static/',
    )

    django.setup()

    #from django.core.management import call_command
    #call_command('shell')
    #quit()

    #-- Run Tests
    from awl.waelsteng import WRunner
    runner = WRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    # in case this is called from setup tools, return a test suite
    return TestSuite()
def get_suite(labels=default_labels):
    #-- Configure Django
    BASE_DIR = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 'bseditor'))

    settings.configure(
        BASE_DIR=BASE_DIR,
        DEBUG=True,
        DATABASES={'default': {
            'ENGINE': 'django.db.backends.sqlite3',
        }},
        ROOT_URLCONF='bseditor.tests.urls',
        MIDDLEWARE_CLASSES=(
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware',
            'django.middleware.common.CommonMiddleware',
            'django.middleware.csrf.CsrfViewMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
        ),
        INSTALLED_APPS=(
            'django.contrib.auth',
            'django.contrib.contenttypes',
            'django.contrib.sessions',
            'django.contrib.admin',
            'django.contrib.staticfiles',
            'awl',
            'bseditor',
            'bseditor.tests',
        ),
        TEMPLATE_DIRS=(os.path.abspath(
            os.path.join(BASE_DIR, 'bseditor/templates')), ),
        STATIC_URL='/static/',
    )

    django.setup()

    #from django.core.management import call_command
    #call_command('shell')
    #quit()

    #-- Run Tests
    from awl.waelsteng import WRunner
    runner = WRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    # in case this is called from setup tools, return a test suite
    return TestSuite()
예제 #5
0
def get_suite(labels=default_labels):
    # -- Configure Django
    BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "dform"))

    settings.configure(
        BASE_DIR=BASE_DIR,
        DEBUG=True,
        DATABASES={"default": {"ENGINE": "django.db.backends.sqlite3"}},
        ROOT_URLCONF="dform.tests.urls",
        MIDDLEWARE_CLASSES=(
            "django.contrib.sessions.middleware.SessionMiddleware",
            "django.middleware.common.CommonMiddleware",
            "django.middleware.csrf.CsrfViewMiddleware",
            "django.contrib.auth.middleware.AuthenticationMiddleware",
            "django.contrib.auth.middleware.SessionAuthenticationMiddleware",
        ),
        INSTALLED_APPS=(
            "django.contrib.auth",
            "django.contrib.contenttypes",
            "django.contrib.sessions",
            "django.contrib.admin",
            "django.contrib.staticfiles",
            "awl",
            "awl.rankedmodel",
            "dform",
            "dform.tests",
        ),
        TEMPLATE_DIRS=(os.path.abspath(os.path.join(BASE_DIR, "dform/templates")),),
        STATIC_URL="/static/",
    )

    django.setup()

    # from django.core.management import call_command
    # call_command('shell')
    # quit()

    # -- Run Tests
    from awl.waelsteng import WRunner

    runner = WRunner(verbosity=1)
    failures = runner.run_tests(labels)
    if failures:
        sys.exit(failures)

    # in case this is called from setup tools, return a test suite
    return TestSuite()
예제 #6
0
    def test_runner(self):
        # hopefully the universe won't implode as we're using our runner to
        # test our runner
        runner = WRunner()

        # check media root handling
        runner.setup_test_environment()
        self.assertTrue(os.path.isdir(self.media_dir))

        # do it again to make sure directory already existing doesn't blow
        # anything up
        runner.setup_test_environment()

        # check test loader
        with self.assertRaises(GotHere):
            runner.setup_databases()

        # -- test various labels work
        expected = [
            'test_same_order (awl.tests.test_ranked.GroupedTests)',
            'test_same_order (awl.tests.test_ranked.AloneTests)',
            'test_too_large (awl.tests.test_ranked.GroupedTests)',
        ]
        suite = runner.build_suite([
            'awl.tests.test_ranked.GroupedTests.test_too_large',
            '=_same_order'])
        self.assert_test_strings(expected, suite)

        # shortcuts only
        expected = [
            'test_same_order (awl.tests.test_ranked.GroupedTests)',
            'test_same_order (awl.tests.test_ranked.AloneTests)',
        ]
        suite = runner.build_suite(['=_same_order'])
        self.assert_test_strings(expected, suite)

        # test no labels at all
        suite = runner.build_suite([])
        self.assertTrue(list(suite))

        # -- check media root cleanup
        with mock.patch("django.test.runner.DiscoverRunner.teardown_databases"):
            # django 1.8 & 1.9 expect different values of old_config, mocked
            # out the super teardown_databases class so we don't care, just
            # want to make sure the post super() call steps get invoked
            runner.teardown_databases(old_config=[])

        self.assertFalse(os.path.exists(self.media_dir))