Commit 1f17fe12 by Christine Lytwynec

Add cov_args and extra_args to python unittest commands

parent dce62ed6
...@@ -27,6 +27,8 @@ __test__ = False # do not collect ...@@ -27,6 +27,8 @@ __test__ = False # do not collect
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
("fasttest", "a", "Run without collectstatic"), ("fasttest", "a", "Run without collectstatic"),
('extra_args=', 'e', 'adds as extra args to the test command'),
('cov_args=', 'c', 'adds as args to coverage for the test run'),
make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
...@@ -43,6 +45,8 @@ def test_system(options): ...@@ -43,6 +45,8 @@ def test_system(options):
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'fasttest': getattr(options, 'fasttest', None), 'fasttest': getattr(options, 'fasttest', None),
'verbosity': getattr(options, 'verbosity', 1), 'verbosity': getattr(options, 'verbosity', 1),
'extra_args': getattr(options, 'extra_args', ''),
'cov_args': getattr(options, 'cov_args', ''),
} }
if test_id: if test_id:
...@@ -73,6 +77,8 @@ def test_system(options): ...@@ -73,6 +77,8 @@ def test_system(options):
("test_id=", "t", "Test id"), ("test_id=", "t", "Test id"),
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
('extra_args=', 'e', 'adds as extra args to the test command'),
('cov_args=', 'c', 'adds as args to coverage for the test run'),
make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
...@@ -88,6 +94,8 @@ def test_lib(options): ...@@ -88,6 +94,8 @@ def test_lib(options):
'failed_only': getattr(options, 'failed', None), 'failed_only': getattr(options, 'failed', None),
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'verbosity': getattr(options, 'verbosity', 1), 'verbosity': getattr(options, 'verbosity', 1),
'extra_args': getattr(options, 'extra_args', ''),
'cov_args': getattr(options, 'cov_args', ''),
} }
if test_id: if test_id:
...@@ -115,6 +123,8 @@ def test_lib(options): ...@@ -115,6 +123,8 @@ def test_lib(options):
@cmdopts([ @cmdopts([
("failed", "f", "Run only failed tests"), ("failed", "f", "Run only failed tests"),
("fail_fast", "x", "Run only failed tests"), ("fail_fast", "x", "Run only failed tests"),
('extra_args=', 'e', 'adds as extra args to the test command'),
('cov_args=', 'c', 'adds as args to coverage for the test run'),
make_option("--verbose", action="store_const", const=2, dest="verbosity"), make_option("--verbose", action="store_const", const=2, dest="verbosity"),
make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"), make_option("-q", "--quiet", action="store_const", const=0, dest="verbosity"),
make_option("-v", "--verbosity", action="count", dest="verbosity", default=1), make_option("-v", "--verbosity", action="count", dest="verbosity", default=1),
...@@ -127,6 +137,8 @@ def test_python(options): ...@@ -127,6 +137,8 @@ def test_python(options):
'failed_only': getattr(options, 'failed', None), 'failed_only': getattr(options, 'failed', None),
'fail_fast': getattr(options, 'fail_fast', None), 'fail_fast': getattr(options, 'fail_fast', None),
'verbosity': getattr(options, 'verbosity', 1), 'verbosity': getattr(options, 'verbosity', 1),
'extra_args': getattr(options, 'extra_args', ''),
'cov_args': getattr(options, 'cov_args', ''),
} }
python_suite = suites.PythonTestSuite('Python Tests', **opts) python_suite = suites.PythonTestSuite('Python Tests', **opts)
......
...@@ -23,6 +23,8 @@ class NoseTestSuite(TestSuite): ...@@ -23,6 +23,8 @@ class NoseTestSuite(TestSuite):
self.report_dir = Env.REPORT_DIR / self.root self.report_dir = Env.REPORT_DIR / self.root
self.test_id_dir = Env.TEST_DIR / self.root self.test_id_dir = Env.TEST_DIR / self.root
self.test_ids = self.test_id_dir / 'noseids' self.test_ids = self.test_id_dir / 'noseids'
self.extra_args = kwargs.get('extra_args', '')
self.cov_args = kwargs.get('cov_args', '')
def __enter__(self): def __enter__(self):
super(NoseTestSuite, self).__enter__() super(NoseTestSuite, self).__enter__()
...@@ -52,8 +54,9 @@ class NoseTestSuite(TestSuite): ...@@ -52,8 +54,9 @@ class NoseTestSuite(TestSuite):
cmd0 = "`which {}`".format(cmd0) cmd0 = "`which {}`".format(cmd0)
cmd = ( cmd = (
"python -m coverage run --rcfile={root}/.coveragerc " "python -m coverage run {cov_args} --rcfile={root}/.coveragerc "
"{cmd0} {cmd_rest}".format( "{cmd0} {cmd_rest}".format(
cov_args=self.cov_args,
root=self.root, root=self.root,
cmd0=cmd0, cmd0=cmd0,
cmd_rest=cmd_rest, cmd_rest=cmd_rest,
...@@ -106,11 +109,12 @@ class SystemTestSuite(NoseTestSuite): ...@@ -106,11 +109,12 @@ class SystemTestSuite(NoseTestSuite):
def cmd(self): def cmd(self):
cmd = ( cmd = (
'./manage.py {system} test --verbosity={verbosity} ' './manage.py {system} test --verbosity={verbosity} '
'{test_id} {test_opts} --traceback --settings=test'.format( '{test_id} {test_opts} --traceback --settings=test {extra}'.format(
system=self.root, system=self.root,
verbosity=self.verbosity, verbosity=self.verbosity,
test_id=self.test_id, test_id=self.test_id,
test_opts=self.test_options_flags, test_opts=self.test_options_flags,
extra=self.extra_args,
) )
) )
...@@ -157,13 +161,14 @@ class LibTestSuite(NoseTestSuite): ...@@ -157,13 +161,14 @@ class LibTestSuite(NoseTestSuite):
def cmd(self): def cmd(self):
cmd = ( cmd = (
"nosetests --id-file={test_ids} {test_id} {test_opts} " "nosetests --id-file={test_ids} {test_id} {test_opts} "
"--with-xunit --xunit-file={xunit_report} " "--with-xunit --xunit-file={xunit_report} {extra}"
"--verbosity={verbosity}".format( "--verbosity={verbosity}".format(
test_ids=self.test_ids, test_ids=self.test_ids,
test_id=self.test_id, test_id=self.test_id,
test_opts=self.test_options_flags, test_opts=self.test_options_flags,
xunit_report=self.xunit_report, xunit_report=self.xunit_report,
verbosity=self.verbosity, verbosity=self.verbosity,
extra=self.extra_args,
) )
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment