Skip to content

Commit

Permalink
mp: Recreate unknown tests in mp._localize
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanholek committed Jan 24, 2021
1 parent 6d9299a commit 2287ab3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nose2/plugins/mp.py
Expand Up @@ -273,10 +273,10 @@ def _localize(self, event):
try:
event.test = self.cases[event.test]
except KeyError:
event.test = self.session.testLoader.failedLoadTests(
'test_not_found',
RuntimeError("Unable to locate test case for %s in "
"main process" % event.test))._tests[0]
# this happens when _flatten augments the test suite
# due to a class or module fixture being present
event.test = self.session.testLoader.loadTestsFromName(
event.test)._tests[0]
# subtest support
if 'subtest' in event.metadata:
message, params = event.metadata.pop('subtest')
Expand Down
26 changes: 26 additions & 0 deletions nose2/tests/functional/test_mp_plugin.py
Expand Up @@ -362,6 +362,19 @@ def test_testcase_class_fixtures_mp(self):
self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
self.assertEqual(proc.poll(), 0)

def test_testcase_class_fixtures_report_mp(self):
proc = self.runIn(
'scenario/class_fixtures',
'-v',
'--plugin=nose2.plugins.mp',
'-N=2',
'test_cf_testcase.Test.test_1')
# report should show correct names for all tests
self.assertTestRunOutputMatches(proc, stderr='test_1 \(test_cf_testcase.Test\) ... ok')
self.assertTestRunOutputMatches(proc, stderr='test_2 \(test_cf_testcase.Test\) ... ok')
self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
self.assertEqual(proc.poll(), 0)

def test_testclass_class_fixtures_and_parameters(self):
proc = self.runIn(
'scenario/test_classes_mp',
Expand Down Expand Up @@ -424,3 +437,16 @@ def test_testcase_module_fixtures_mp(self):
# XXX mp plugin runs the entire module if a module fixture is detected
self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
self.assertEqual(proc.poll(), 0)

def test_testcase_module_fixtures_report_mp(self):
proc = self.runIn(
'scenario/module_fixtures',
'-v',
'--plugin=nose2.plugins.mp',
'-N=2',
'test_mf_testcase.Test.test_1')
# report should show correct names for all tests
self.assertTestRunOutputMatches(proc, stderr='test_1 \(test_mf_testcase.Test\) ... ok')
self.assertTestRunOutputMatches(proc, stderr='test_2 \(test_mf_testcase.Test\) ... ok')
self.assertTestRunOutputMatches(proc, stderr='Ran 2 tests')
self.assertEqual(proc.poll(), 0)

0 comments on commit 2287ab3

Please sign in to comment.