提交 c31cb890 编写于 作者: C Cleber Rosa

selftests/unit/test_xunit.py: junit XSD file is only used in one test

So it makes no sense to use in the setup phase.  Let's move that
closer to its actual usage.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 38d8fd06
......@@ -52,9 +52,6 @@ class xUnitSucceedTest(unittest.TestCase):
self.test1 = SimpleTest(job=self.job, base_logdir=self.tmpdir)
self.test1._Test__status = 'PASS'
self.test1.time_elapsed = 1.23
junit_xsd = os.path.join(os.path.dirname(__file__),
os.path.pardir, ".data", 'junit-4.xsd')
self.junit = os.path.abspath(junit_xsd)
def tearDown(self):
errs = []
......@@ -87,12 +84,14 @@ class xUnitSucceedTest(unittest.TestCase):
els = dom.getElementsByTagName('testcase')
self.assertEqual(len(els), 1)
with open(self.junit, 'r') as f:
junit_xsd = os.path.abspath(os.path.join(os.path.dirname(__file__),
os.path.pardir, ".data", 'junit-4.xsd'))
with open(junit_xsd, 'r') as f:
xmlschema = etree.XMLSchema(etree.parse(f)) # pylint: disable=I1101
# pylint: disable=I1101
self.assertTrue(xmlschema.validate(etree.parse(BytesIO(xml))),
"Failed to validate against %s, content:\n%s\nerror log:\n%s" %
(self.junit, xml, xmlschema.error_log))
(junit_xsd, xml, xmlschema.error_log))
def test_max_test_log_size(self):
log = tempfile.NamedTemporaryFile(dir=self.tmpdir, delete=False)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册