提交 c84d9eb7 编写于 作者: L Lukáš Doktor

avocado.core.test: Always use "test" as methodName in dry-run

The --dry-run replaces the test class with a special one instead. When
the original class used a different but "test" methodName this fails
during __init__ as unittest requires the methodName attribute to exists.
This patch always changes the methodName to "test", which is defined in
the fake dry-run class.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 69c2a728
...@@ -805,6 +805,8 @@ class SkipTest(Test): ...@@ -805,6 +805,8 @@ class SkipTest(Test):
super_kwargs[arg] = kwargs[arg] super_kwargs[arg] = kwargs[arg]
elif args: elif args:
super_kwargs[arg] = args.pop() super_kwargs[arg] = args.pop()
# The methodName might not exist in SkipTest, make sure it's self.test
super_kwargs["methodName"] = "test"
super(SkipTest, self).__init__(**super_kwargs) super(SkipTest, self).__init__(**super_kwargs)
def setUp(self): def setUp(self):
......
...@@ -440,7 +440,7 @@ class RunnerOperationTest(unittest.TestCase): ...@@ -440,7 +440,7 @@ class RunnerOperationTest(unittest.TestCase):
def test_dry_run(self): def test_dry_run(self):
os.chdir(basedir) os.chdir(basedir)
cmd = ("./scripts/avocado run --sysinfo=off passtest.py failtest.py " cmd = ("./scripts/avocado run --sysinfo=off passtest.py failtest.py "
"errortest.py --json - --mux-inject foo:1 bar:2 baz:3 foo:foo:a" "gendata.py --json - --mux-inject foo:1 bar:2 baz:3 foo:foo:a"
" foo:bar:b foo:baz:c bar:bar:bar --dry-run") " foo:bar:b foo:baz:c bar:bar:bar --dry-run")
result = json.loads(process.run(cmd).stdout) result = json.loads(process.run(cmd).stdout)
debuglog = result['debuglog'] debuglog = result['debuglog']
...@@ -450,8 +450,8 @@ class RunnerOperationTest(unittest.TestCase): ...@@ -450,8 +450,8 @@ class RunnerOperationTest(unittest.TestCase):
self.assertIn('/tmp', debuglog) # Use tmp dir, not default location self.assertIn('/tmp', debuglog) # Use tmp dir, not default location
self.assertEqual(result['job_id'], u'0' * 40) self.assertEqual(result['job_id'], u'0' * 40)
# Check if all tests were skipped # Check if all tests were skipped
self.assertEqual(result['skip'], 3) self.assertEqual(result['skip'], 4)
for i in xrange(3): for i in xrange(4):
test = result['tests'][i] test = result['tests'][i]
self.assertEqual(test['fail_reason'], self.assertEqual(test['fail_reason'],
u'Test skipped due to --dry-run') u'Test skipped due to --dry-run')
...@@ -460,7 +460,7 @@ class RunnerOperationTest(unittest.TestCase): ...@@ -460,7 +460,7 @@ class RunnerOperationTest(unittest.TestCase):
# from test. # from test.
for line in ("/:foo ==> 1", "/:baz ==> 3", "/foo:foo ==> a", for line in ("/:foo ==> 1", "/:baz ==> 3", "/foo:foo ==> a",
"/foo:bar ==> b", "/foo:baz ==> c", "/bar:bar ==> bar"): "/foo:bar ==> b", "/foo:baz ==> c", "/bar:bar ==> bar"):
self.assertEqual(log.count(line), 3) self.assertEqual(log.count(line), 4)
def test_invalid_python(self): def test_invalid_python(self):
os.chdir(basedir) os.chdir(basedir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册