51 lines
1.1 KiB
Python
51 lines
1.1 KiB
Python
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'],
|
|
AI_BLOCKER_CONF={
|
|
"ua_list": ["Googlebot", "Bingbot"],
|
|
},
|
|
)
|
|
|
|
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:]) |