未验证 提交 6ae8da64 编写于 作者: C Caio Carrara

Merge remote-tracking branch 'clebergnu/ldoktor_recursive_rework_hotfix'

Signed-off-by: NCaio Carrara <ccarrara@redhat.com>
...@@ -65,7 +65,7 @@ class AvocadoModule(object): ...@@ -65,7 +65,7 @@ class AvocadoModule(object):
for name in statement.names: for name in statement.names:
if name.name == 'avocado': if name.name == 'avocado':
if name.asname is not None: if name.asname is not None:
self.mod_import = name.nasname self.mod_import = name.asname
else: else:
self.mod_import = name.name self.mod_import = name.name
......
# This currently only discovers 2 tests in avocado due to bug
import avocado as foo
import avocado as bar # pylint: disable=W0404
from avocado import Test as Foo
from avocado import Test as Bar # pylint: disable=W0404
class Test1(foo.Test):
def test1(self):
pass
class Test2(bar.Test):
def test2(self):
pass
class Test3(Foo):
def test3(self):
pass
class Test4(Bar):
def test4(self):
pass
...@@ -197,6 +197,22 @@ class SampleTest(TestCase): ...@@ -197,6 +197,22 @@ class SampleTest(TestCase):
class LoaderTest(unittest.TestCase): class LoaderTest(unittest.TestCase):
def _check_discovery(self, exps, tests):
self.assertEqual(len(exps), len(tests), "Total count of tests not "
"as expected (%s != %s)\nexps: %s\ntests: %s"
% (len(exps), len(tests), exps, tests))
try:
for exp, tst in zip(exps, tests):
# Test class
self.assertEqual(tst[0], exp[0])
# Test name (path)
# py2 reports relpath, py3 abspath
self.assertEqual(os.path.abspath(tst[1]['name']),
os.path.abspath(exp[1]))
except AssertionError as details:
raise AssertionError("%s\nexps: %s\ntests:%s"
% (details, exps, tests))
def setUp(self): def setUp(self):
self.loader = loader.FileLoader(None, {}) self.loader = loader.FileLoader(None, {})
self.queue = multiprocessing.Queue() self.queue = multiprocessing.Queue()
...@@ -494,6 +510,16 @@ class LoaderTest(unittest.TestCase): ...@@ -494,6 +510,16 @@ class LoaderTest(unittest.TestCase):
# py2 reports relpath, py3 abspath # py2 reports relpath, py3 abspath
self.assertEqual(os.path.abspath(tst[1]['name']), os.path.abspath(exp[1])) self.assertEqual(os.path.abspath(tst[1]['name']), os.path.abspath(exp[1]))
def test_double_import(self):
# This is currently broken in Avocado, so let's just document the
# current behavior.
path = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'.data', 'loader_instrumented', 'double_import.py')
tests = self.loader.discover(path)
exps = [('Test2', 'selftests/.data/loader_instrumented/double_import.py:Test2.test2'),
('Test4', 'selftests/.data/loader_instrumented/double_import.py:Test4.test4')]
self._check_discovery(exps, tests)
def tearDown(self): def tearDown(self):
shutil.rmtree(self.tmpdir) shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册