Skip to content

Commit

Permalink
Added manage.py test --testrunner tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthijskooijman authored and timgraham committed Aug 23, 2018
1 parent 108c04f commit 69071e7
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions tests/test_runner/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ def test_bad_test_runner(self):
call_command('test', 'sites', testrunner='test_runner.NonexistentRunner')


class CustomTestRunnerOptionsTests(AdminScriptTestCase):

class CustomTestRunnerOptionsSettingsTests(AdminScriptTestCase):
"""
Custom runners can add command line arguments. The runner is specified
through a settings file.
"""
def setUp(self):
settings = {
'TEST_RUNNER': '\'test_runner.runner.CustomOptionsTestRunner\'',
Expand Down Expand Up @@ -187,6 +190,34 @@ def test_all_options_given(self):
self.assertOutput(out, 'bar:foo:31337')


class CustomTestRunnerOptionsCmdlineTests(AdminScriptTestCase):
"""
Custom runners can add command line arguments when the runner is specified
using --testrunner.
"""
def setUp(self):
self.write_settings('settings.py')

def tearDown(self):
self.remove_settings('settings.py')

def test_testrunner_equals(self):
args = [
'test', '--testrunner=test_runner.runner.CustomOptionsTestRunner',
'--option_a=bar', '--option_b=foo', '--option_c=31337'
]
out, err = self.run_django_admin(args, 'test_project.settings')
self.assertNoOutput(err)
self.assertOutput(out, 'bar:foo:31337')

def test_no_testrunner(self):
args = ['test', '--testrunner']
out, err = self.run_django_admin(args, 'test_project.settings')
self.assertIn('usage', err)
self.assertNotIn('Traceback', err)
self.assertNoOutput(out)


class Ticket17477RegressionTests(AdminScriptTestCase):
def setUp(self):
self.write_settings('settings.py')
Expand Down

0 comments on commit 69071e7

Please sign in to comment.