diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-09 22:41:57 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-02-10 21:41:19 +0100 |
| commit | 1b8af4cfa023161924a45fb572399d2f3071bf5b (patch) | |
| tree | 04d44e1f35094798ba804bae6e4d16a5318f199a /tests/test_runner | |
| parent | c7a6996df7e77bc3b9c5e581e67d766627ebabec (diff) | |
Disallowed importing concrete models without an application.
Removed fragile algorithm to find which application a model belongs to.
Fixed #21680, #21719. Refs #21794.
Diffstat (limited to 'tests/test_runner')
| -rw-r--r-- | tests/test_runner/runner.py | 20 | ||||
| -rw-r--r-- | tests/test_runner/tests.py | 21 |
2 files changed, 21 insertions, 20 deletions
diff --git a/tests/test_runner/runner.py b/tests/test_runner/runner.py new file mode 100644 index 0000000000..8dc4c74111 --- /dev/null +++ b/tests/test_runner/runner.py @@ -0,0 +1,20 @@ +from django.test.runner import DiscoverRunner + + +class CustomOptionsTestRunner(DiscoverRunner): + + def __init__(self, verbosity=1, interactive=True, failfast=True, option_a=None, option_b=None, option_c=None, **kwargs): + super(CustomOptionsTestRunner, self).__init__(verbosity=verbosity, interactive=interactive, + failfast=failfast) + self.option_a = option_a + self.option_b = option_b + self.option_c = option_c + + @classmethod + def add_arguments(cls, parser): + parser.add_argument('--option_a', '-a', action='store', dest='option_a', default='1'), + parser.add_argument('--option_b', '-b', action='store', dest='option_b', default='2'), + parser.add_argument('--option_c', '-c', action='store', dest='option_c', default='3'), + + def run_tests(self, test_labels, extra_tests=None, **kwargs): + print("%s:%s:%s" % (self.option_a, self.option_b, self.option_c)) diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index d94d264321..4a3f24515c 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -151,30 +151,11 @@ class ManageCommandTests(unittest.TestCase): testrunner='test_runner.NonExistentRunner') -class CustomOptionsTestRunner(DiscoverRunner): - - def __init__(self, verbosity=1, interactive=True, failfast=True, option_a=None, option_b=None, option_c=None, **kwargs): - super(CustomOptionsTestRunner, self).__init__(verbosity=verbosity, interactive=interactive, - failfast=failfast) - self.option_a = option_a - self.option_b = option_b - self.option_c = option_c - - @classmethod - def add_arguments(cls, parser): - parser.add_argument('--option_a', '-a', action='store', dest='option_a', default='1'), - parser.add_argument('--option_b', '-b', action='store', dest='option_b', default='2'), - parser.add_argument('--option_c', '-c', action='store', dest='option_c', default='3'), - - def run_tests(self, test_labels, extra_tests=None, **kwargs): - print("%s:%s:%s" % (self.option_a, self.option_b, self.option_c)) - - class CustomTestRunnerOptionsTests(AdminScriptTestCase): def setUp(self): settings = { - 'TEST_RUNNER': '\'test_runner.tests.CustomOptionsTestRunner\'', + 'TEST_RUNNER': '\'test_runner.runner.CustomOptionsTestRunner\'', } self.write_settings('settings.py', sdict=settings) |
