[Piglit] [PATCH 2/3] backend_test.py: Add test for suffix addition
Dylan Baker
baker.dylan.c at gmail.com
Fri Oct 3 15:25:02 PDT 2014
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/tests/backends_tests.py | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/framework/tests/backends_tests.py b/framework/tests/backends_tests.py
index 00d7e1a..b39cb93 100644
--- a/framework/tests/backends_tests.py
+++ b/framework/tests/backends_tests.py
@@ -317,3 +317,27 @@ def test_junit_prefix():
# then it's first element (the first testcase)
elem = etree.parse(f).getroot()[0][0]
nt.ok_(elem.attrib['classname'].startswith('piglit.'))
+
+
+def test_junit_suffix():
+ """JUnitBackend.write_test adds a suffix when configured."""
+ with utils.tempdir() as tdir:
+ test_name = 'a/test/group/test1'
+ result = results.TestResult({
+ 'time': 1.2345,
+ 'result': 'pass',
+ 'out': 'this is stdout',
+ 'err': 'this is stderr',
+ })
+ test = backends.JUnitBackend(tdir, junit_test_suffix='.foo')
+ test.initialize(BACKEND_INITIAL_META)
+ test.write_test(test_name, result)
+ test.finalize()
+
+ with open(os.path.join(tdir, 'results.xml'), 'r') as f:
+ # Get the root (testsuites), then it's first element (testsuite),
+ # then it's first element (the first testcase)
+ elem = etree.parse(f).getroot()[0][0]
+ nt.ok_(elem.attrib['name'].endswith('.foo'),
+ msg='suffix ".foo" not appended to test name. {}'.format(
+ elem.attrib['name']))
--
2.1.2
More information about the Piglit
mailing list