diff --git a/ai_blocker/tests.py b/ai_blocker/tests.py index 60b8922..d46efe0 100644 --- a/ai_blocker/tests.py +++ b/ai_blocker/tests.py @@ -1,7 +1,7 @@ from django.test import TestCase -from ai_blocker.ualist_backers import ConfigBackedUAList -from middleware import load_backing_class +from .ualist_backers import ConfigBackedUAList +from .middleware import load_backing_class # Create your tests here. class BackerConfigTestCase(TestCase): diff --git a/test_app.py b/test_app.py new file mode 100644 index 0000000..bc601cf --- /dev/null +++ b/test_app.py @@ -0,0 +1,48 @@ +import sys + +try: + import django + from django.conf import settings + + settings.configure( + DEBUG=True, + USE_TZ=True, + DATABASES={ + "default": { + "ENGINE": "django.db.backends.sqlite3", + } + }, + # ROOT_URLCONF="test_app.urls", + INSTALLED_APPS=[ + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sites", + "ai_blocker", + ], + SITE_ID=1, + NOSE_ARGS=['-s'], + FIXTURE_DIRS=['ai_blocker/fixtures'] + ) + + django.setup() + + from django.test.utils import get_runner + + +except ImportError: + raise ImportError("To fix this error, run: pipenv install") + + +def run_tests(*test_args): + if not test_args: + test_args = ['ai_blocker.tests'] + + TestRunner = get_runner(settings) + test_runner = TestRunner() + failures = test_runner.run_tests(test_args) + if failures: + sys.exit(failures) + + +if __name__ == '__main__': + run_tests(*sys.argv[1:]) \ No newline at end of file