From 994531a1c248812008f698a7c2f6cfb7eddf2170 Mon Sep 17 00:00:00 2001 From: Albert Tugushev Date: Fri, 1 Jan 2016 11:39:44 +0300 Subject: [PATCH 1/1] Add new test runner Also move test.py file to tests directory --- linaro_django_pagination/tests/__init__.py | 0 linaro_django_pagination/tests/runner.py | 36 +++++++++++++++++++ .../{tests.py => tests/test_main.py} | 14 ++++---- setup.py | 10 ++---- 4 files changed, 46 insertions(+), 14 deletions(-) create mode 100644 linaro_django_pagination/tests/__init__.py create mode 100755 linaro_django_pagination/tests/runner.py rename linaro_django_pagination/{tests.py => tests/test_main.py} (96%) diff --git a/linaro_django_pagination/tests/__init__.py b/linaro_django_pagination/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/linaro_django_pagination/tests/runner.py b/linaro_django_pagination/tests/runner.py new file mode 100755 index 0000000..44c6f69 --- /dev/null +++ b/linaro_django_pagination/tests/runner.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python +import django +import doctest +import sys + +from django.conf import settings + + +def runtests(): + if not settings.configured: + # Configure test environment + settings.configure( + SECRET_KEY='fake-key', + INSTALLED_APPS=( + 'linaro_django_pagination', + ), + ) + + try: + django.setup() + except AttributeError: # for Django 1.6 compatible + pass + + from django.test.utils import get_runner + + TestRunner = get_runner(settings) + test_runner = TestRunner() + failures = test_runner.run_tests( + ["linaro_django_pagination.tests"], + extra_tests=[doctest.DocTestSuite('linaro_django_pagination.tests.test_main')] + ) + sys.exit(bool(failures)) + + +if __name__ == '__main__': + runtests() diff --git a/linaro_django_pagination/tests.py b/linaro_django_pagination/tests/test_main.py similarity index 96% rename from linaro_django_pagination/tests.py rename to linaro_django_pagination/tests/test_main.py index 90468d5..ba1baa1 100644 --- a/linaro_django_pagination/tests.py +++ b/linaro_django_pagination/tests/test_main.py @@ -170,30 +170,30 @@ >>> class HttpRequest(DjangoHttpRequest): ... page = lambda self, suffix: 1 ->>> t.render(Context({'var': range(21), 'request': HttpRequest()})) +>>> t.render(Context({'var': range(21), 'request': HttpRequest()})) #doctest: +ELLIPSIS u'\\n...\\n...