Skip to content

Commit

Permalink
Fix tests on modern Django
Browse files Browse the repository at this point in the history
  • Loading branch information
vdboor committed Nov 16, 2021
1 parent d951fff commit 0877f2d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
5 changes: 1 addition & 4 deletions fluentcms_cookielaw/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def test_rendering(self):
</div>
</div>""",
)
self.assertHTMLEqual(
str(output.media),
'<script type="text/javascript" src="/static/fluentcms_cookielaw/js/cookielaw.js"></script>',
)
self.assertIn("/static/fluentcms_cookielaw/js/cookielaw.js", str(output.media))

self.assertEqual(str(item), "Do you like cookies?")
76 changes: 42 additions & 34 deletions runtests.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,67 @@
#!/usr/bin/env python
import sys

import django
from django.conf import settings, global_settings as default_settings
from django.conf import settings
from django.core.management import execute_from_command_line

if not settings.configured:
settings.configure(
DATABASES = {
'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:',},
DATABASES={
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": ":memory:",
},
},
SITE_ID = 1,
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sites',
'fluent_contents',
'fluent_contents.tests.testapp',
'fluentcms_cookielaw',
SITE_ID=1,
INSTALLED_APPS=(
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sites",
"fluent_contents",
"fluent_contents.tests.testapp",
"fluentcms_cookielaw",
),
MIDDLEWARE_CLASSES = (),
TEMPLATES = [
MIDDLEWARE=(),
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': (),
'OPTIONS': {
'loaders': (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": (),
"OPTIONS": {
"loaders": (
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
),
'context_processors': (
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
"context_processors": (
"django.template.context_processors.debug",
"django.template.context_processors.i18n",
"django.template.context_processors.media",
"django.template.context_processors.request",
"django.template.context_processors.static",
"django.contrib.auth.context_processors.auth",
),
},
},
],
FLUENT_CONTENTS_CACHE_OUTPUT = False,
TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner' if django.VERSION < (1,6) else 'django.test.runner.DiscoverRunner',
STATIC_URL = '/static/'
FLUENT_CONTENTS_CACHE_OUTPUT=False,
TEST_RUNNER="django.test.runner.DiscoverRunner",
DEFAULT_AUTO_FIELD="django.db.models.BigAutoField",
STATIC_URL="/static/",
)

DEFAULT_TEST_APPS = [
'fluentcms_cookielaw',
"fluentcms_cookielaw",
]


def runtests():
other_args = list(filter(lambda arg: arg.startswith('-'), sys.argv[1:]))
test_apps = list(filter(lambda arg: not arg.startswith('-'), sys.argv[1:])) or DEFAULT_TEST_APPS
argv = sys.argv[:1] + ['test', '--traceback'] + other_args + test_apps
other_args = list(filter(lambda arg: arg.startswith("-"), sys.argv[1:]))
test_apps = (
list(filter(lambda arg: not arg.startswith("-"), sys.argv[1:])) or DEFAULT_TEST_APPS
)
argv = sys.argv[:1] + ["test", "--traceback"] + other_args + test_apps
execute_from_command_line(argv)

if __name__ == '__main__':

if __name__ == "__main__":
runtests()

0 comments on commit 0877f2d

Please sign in to comment.