From 99fddfcc23a9d8aa1e6aa6c10cf9c1811f9d05e3 Mon Sep 17 00:00:00 2001 From: Tyson Clugg Date: Mon, 14 Dec 2015 12:43:49 +1100 Subject: [PATCH] Try to use dddp.test.django_todos.tests in test suite. --- dddp/test/__init__.py | 2 +- dddp/test/django_todos/tests.py | 35 +++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/dddp/test/__init__.py b/dddp/test/__init__.py index d1fa05a..8740a3b 100644 --- a/dddp/test/__init__.py +++ b/dddp/test/__init__.py @@ -13,5 +13,5 @@ def run_tests(): dddp.greenify() django.setup() test_runner = get_runner(settings)() - failures = test_runner.run_tests(['dddp']) + failures = test_runner.run_tests(['dddp', 'dddp.test.django_todos']) sys.exit(bool(failures)) diff --git a/dddp/test/django_todos/tests.py b/dddp/test/django_todos/tests.py index 7ce503c..70500dc 100644 --- a/dddp/test/django_todos/tests.py +++ b/dddp/test/django_todos/tests.py @@ -1,3 +1,34 @@ -from django.test import TestCase +"""Django Todos test suite.""" -# Create your tests here. +import doctest +import os +import unittest + +os.environ['DJANGO_SETTINGS_MODULE'] = 'dddp.test.test_project.settings' + +DOCTEST_MODULES = [ +] + + +class NoOpTest(unittest.TestCase): + def test_noop(self): + assert True + + +def load_tests(loader, tests, pattern): + """Specify which test cases to run.""" + del pattern + suite = unittest.TestSuite() + # add all TestCase classes from this (current) module + for attr in globals().values(): + try: + if not issubclass(attr, unittest.TestCase): + continue # not subclass of TestCase + except TypeError: + continue # not a class + tests = loader.loadTestsFromTestCase(attr) + suite.addTests(tests) + # add doctests defined in DOCTEST_MODULES + for doctest_module in DOCTEST_MODULES: + suite.addTest(doctest.DocTestSuite(doctest_module)) + return suite