[Piglit] [PATCH 1/3] backend_tests.py: add test for piglit. prefix

Dylan Baker baker.dylan.c at gmail.com
Fri Oct 3 15:25:01 PDT 2014


Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/tests/backends_tests.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/framework/tests/backends_tests.py b/framework/tests/backends_tests.py
index 177225d..00d7e1a 100644
--- a/framework/tests/backends_tests.py
+++ b/framework/tests/backends_tests.py
@@ -295,3 +295,25 @@ def test_junit_skips_bad_tests():
             test.finalize()
         except etree.XMLSyntaxError as e:
             raise AssertionError(e)
+
+
+def test_junit_prefix():
+    """JUnitBacked.write_test adds a prefix to test names."""
+    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)
+        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['classname'].startswith('piglit.'))
-- 
2.1.2



More information about the Piglit mailing list