Beispiel #1
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'])
Beispiel #2
0
    def run_tests(self):
        """
        Fire up the Django test suite developed for version 1.2
        """
        if self.database == 'postgres':
            databases = {
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.postgis',
                    'NAME': 'test_db',
                    'HOST': '127.0.0.1',
                    'USER': '******',
                    'PASSWORD': '',
                }
            }

        else:
            databases = {
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.spatialite',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                }
            }
        conf = {
            'DATABASES':
            databases,
            'INSTALLED_APPS':
            self.INSTALLED_APPS + self.apps,
            'STATIC_URL':
            '/static/',
            'MIDDLEWARE': [
                'django.contrib.auth.middleware.AuthenticationMiddleware',
                'django.contrib.messages.middleware.MessageMiddleware',
                'django.contrib.sessions.middleware.SessionMiddleware',
            ]
        }
        if 'SPATIALITE_LIBRARY_PATH' in os.environ:
            # If you get SpatiaLite-related errors, refer to this document
            # to find out the proper SPATIALITE_LIBRARY_PATH value
            # for your platform.
            # https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/spatialite/
            #
            # Example for macOS (with spatialite-tools installed using brew):
            # $ export SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'
            conf['SPATIALITE_LIBRARY_PATH'] = os.getenv(
                'SPATIALITE_LIBRARY_PATH')
        if django.VERSION >= (1, 8, 0):
            conf['TEMPLATES'] = self.TEMPLATES,
        settings.configure(**conf)
        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()
        if django.VERSION >= (1, 6, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module
            from django.test.runner import DiscoverRunner as Runner
        else:
            from django.test.simple import DjangoTestSuiteRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #3
0
def runtests(*test_args):
    if not test_args:
        test_args = ['vies']
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    failures = Runner().run_tests(test_args, verbosity=1, interactive=True)
    sys.exit(bool(failures))
Beispiel #4
0
    def run_tests(self):
        """
        Fire up the Django test suite developed for version 1.2
        """
        settings.configure(
            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,
        )

        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()
        if django.VERSION >= (1, 6, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module
            from django.test.runner import DiscoverRunner as Runner
        else:
            from django.test.simple import DjangoTestSuiteRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #5
0
    def run_tests(self):
        """
        Fire up the Django test suite developed for version 1.2
        """
        settings.configure(
            DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                    'USER': '',
                    'PASSWORD': '',
                    'HOST': '',
                    'PORT': '',
                }
            },
            INSTALLED_APPS=self.apps,
        )

        # Setup configuration
        django.setup()

        from django.test.runner import DiscoverRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            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)
Beispiel #7
0
def runtests(*test_args, **kwargs):
    if django.VERSION[:2] >= (1, 7):
        django.setup()
    if 'south' in settings.INSTALLED_APPS and south_installed:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_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)
Beispiel #8
0
def runtests(*test_args):
    if not test_args:
        test_args = ['tests']

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

    try:
        from django.test.runner import DiscoverRunner as Runner
    except ImportError:
        from django.test.simple import DjangoTestSuiteRunner as Runner
    failures = Runner(verbosity=1, interactive=True,
                      failfast=False).run_tests(test_args)
    sys.exit(failures)
Beispiel #9
0
def runtests(*test_args, **kwargs):
    if 'south' in settings.INSTALLED_APPS:
        from south.management.commands import patch_for_test_db_setup
        patch_for_test_db_setup()

    if not test_args:
        test_args = ['pybb']
    parent = dirname(abspath(__file__))
    sys.path.insert(0, parent)
    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)
Beispiel #10
0
    def run_tests(self):
        """
        Fire up the Django test suite developed for version 1.2
        """
        settings.configure(
            DATABASES={
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.spatialite',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                    'USER': '',
                    'PASSWORD': '',
                    'HOST': '',
                    'PORT': '',
                }
            },
            INSTALLED_APPS=self.INSTALLED_APPS + self.apps,
            SPATIALITE_LIBRARY_PATH='mod_spatialite',
            TEMPLATES=[
                {
                    'BACKEND':
                    'django.template.backends.django.DjangoTemplates',
                    'DIRS': [],
                    'APP_DIRS': True,
                    'OPTIONS': {
                        "context_processors": [
                            "django.contrib.auth.context_processors.auth",
                            "django.contrib.messages.context_processors.messages",
                        ]
                    },
                },
            ],
            MIDDLEWARE=[
                'django.contrib.auth.middleware.AuthenticationMiddleware',
                'django.contrib.messages.middleware.MessageMiddleware',
                'django.contrib.sessions.middleware.SessionMiddleware',
            ])

        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()
        if django.VERSION >= (1, 6, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module
            from django.test.runner import DiscoverRunner as Runner
        else:
            from django.test.simple import DjangoTestSuiteRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #11
0
def runtests(*test_args):
    if not test_args:
        test_args = ['tests']

    os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'

    import django
    if hasattr(django, 'setup'):
        django.setup()

    parent = os.path.dirname(os.path.abspath(__file__))
    sys.path.insert(0, parent)
    from django.test.runner import DiscoverRunner as Runner
    failures = Runner(verbosity=1, interactive=True,
                      failfast=False).run_tests(test_args)
    sys.exit(failures)
Beispiel #12
0
    def run_tests(self):

        django_settings = {
            'DATABASES': {
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                }
            },
            'INSTALLED_APPS': self.INSTALLED_APPS + self.apps,
            'STATIC_URL': '/static/',
            'ROOT_URLCONF': 'generic_scaffold.tests',
            'SILENCED_SYSTEM_CHECKS': ['1_7.W001']
        }

        if django.VERSION >= (1, 8, 0):
            django_settings['TEMPLATES'] = [{
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                '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',
                    ],
                },
            }]

        django_settings['MIDDLEWARE'] = [
            'django.contrib.sessions.middleware.SessionMiddleware',
            'django.contrib.auth.middleware.AuthenticationMiddleware',
            'django.contrib.messages.middleware.MessageMiddleware'
        ]

        settings.configure(**django_settings)

        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()

        from django.test.runner import DiscoverRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #13
0
def runtests():
    if not settings.configured:
        settings.configure(**get_settings())

    # Compatibility with Django 1.7's stricter initialization
    if hasattr(django, 'setup'):
        django.setup()

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

    from django.test.runner import DiscoverRunner as Runner
    # reminder to self: an ImportError in the tests may either turn up
    # or may cause this thing to barf with this crap:
    # AttributeError: 'module' object has no attribute 'tests'
    test_args = ['.']
    failures = Runner(verbosity=2, interactive=True,
                      failfast=False).run_tests(test_args)
    sys.exit(failures)
    def run_tests(self):
        """
        Fire up the Django test suite developed for version 1.2
        """
        if self.database == 'postgres':
            databases = {
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.postgis',
                    'NAME': 'test_db',
                    'HOST': '127.0.0.1',
                    'USER': '******',
                    'PASSWORD': '',
                }
            }

        else:
            databases = {
                'default': {
                    'ENGINE': 'django.contrib.gis.db.backends.spatialite',
                    'NAME': os.path.join(self.DIRNAME, 'database.db'),
                }
            }
        conf = {
            'DATABASES': databases,
            'INSTALLED_APPS': self.INSTALLED_APPS + self.apps,
            'STATIC_URL': '/static/',
        }
        if django.VERSION >= (1, 8, 0):
            conf['TEMPLATES'] = self.TEMPLATES,
        settings.configure(**conf)
        if django.VERSION >= (1, 7, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.7/#standalone-scripts
            django.setup()
        if django.VERSION >= (1, 6, 0):
            # see: https://docs.djangoproject.com/en/dev/releases/1.6/#discovery-of-tests-in-any-test-module
            from django.test.runner import DiscoverRunner as Runner
        else:
            from django.test.simple import DjangoTestSuiteRunner as Runner

        failures = Runner().run_tests(self.apps, verbosity=1)
        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #15
0
def run_tests():
    import django
    from django.conf import global_settings
    from django.conf import settings

    if django.VERSION >= (1, 10):
        middleware_setting = 'MIDDLEWARE'
    else:
        middleware_setting = 'MIDDLEWARE_CLASSES'

    middleware = list(getattr(global_settings, middleware_setting) or [])
    middleware.append('corsheaders.middleware.CorsMiddleware')

    config = {
        'INSTALLED_APPS': [
            'corsheaders',
        ],
        'DATABASES': {
            'default': {
                'ENGINE': 'django.db.backends.sqlite3',
                'TEST_NAME': ':memory:',
            },
        },
        'ROOT_URLCONF': 'corsheaders.tests',
        middleware_setting: middleware,
    }
    settings.configure(**config)

    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'])
Beispiel #16
0
    def run_tests(self):
        """
        Fire up the Django test suite
        """
        conf = {
            'DATABASES': {
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3',
                    'NAME': 'database.db',
                }
            },
            'INSTALLED_APPS': [
                'django.contrib.admin',
                'django.contrib.auth',
                'django.contrib.contenttypes',
                'django.contrib.sessions',
                'django.contrib.messages',
                'django.contrib.staticfiles',
                'jstree',
            ],
            'STATIC_URL':
            '/static/',
            'TEMPLATES': [{
                'BACKEND': 'django.template.backends.django.DjangoTemplates',
                'OPTIONS': {
                    'context_processors': [
                        'django.contrib.auth.context_processors.auth',
                        'django.template.context_processors.debug',
                        'django.template.context_processors.i18n',
                        'django.template.context_processors.media',
                        'django.template.context_processors.static',
                        'django.template.context_processors.tz',
                        'django.contrib.messages.context_processors.messages',
                    ],
                },
                'APP_DIRS': True,
            }],
            'LOGGING_CONFIG':
            None,
            'LOGGING':
            None,
            'FORCE_SCRIPT_NAME':
            None,
            'DEBUG':
            True,
            'DEFAULT_INDEX_TABLESPACE':
            None,
            'DEFAULT_TABLESPACE':
            None,
            'MIDDLEWARE': [
                'django.middleware.security.SecurityMiddleware',
                'django.contrib.sessions.middleware.SessionMiddleware',
                'django.middleware.common.CommonMiddleware',
                'django.middleware.csrf.CsrfViewMiddleware',
                'django.contrib.auth.middleware.AuthenticationMiddleware',
                'django.contrib.messages.middleware.MessageMiddleware',
                'django.middleware.clickjacking.XFrameOptionsMiddleware',
            ]
        }

        settings.configure(**conf)
        django.setup()

        failures = Runner().run_tests(self.apps, verbosity=1)

        if failures:  # pragma: no cover
            sys.exit(failures)
Beispiel #17
0
def runtests(*args, **kwargs):
    sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
    test_runner = Runner(**kwargs)
    failures = test_runner.run_tests(["django_handlebars"])
    sys.exit(failures)
Beispiel #18
0

if __name__ == '__main__':
    # Initialize app in Django 1.7 and above
    setup()

    # Log memcache errors to console
    from django_pylibmc.memcached import log
    handler = logging.StreamHandler()
    handler.setLevel(logging.DEBUG)
    log.addHandler(handler)

    # Test that the cache is working at all
    from django.core.cache import cache
    assert cache
    test_val = 'The test passed'
    assert cache.set('test', test_val), "Could not set cache value"
    cache_val = cache.get('test')
    assert cache_val == test_val, "Could not get from cache"

    # Ignore memcache errors during tests
    handler.setLevel(logging.CRITICAL)

    # Run the tests
    runner = Runner()
    try:
        old_config = runner.setup_databases()
        unittest.main()
    finally:
        runner.teardown_databases(old_config)