diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-08-03 13:29:51 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-08-31 16:04:34 -0700 |
commit | d914e30fa26cf945a15f2041a3f20f283b35bc9c (patch) | |
tree | 52bf2c162535b93938c42c7196c93bbc91ac3fc7 /unittests | |
parent | 6e169b1e56bd90c7a556bc45cab2a8847ffaaf8d (diff) |
framework/backends/junit.py: Split _write into a separate class.
This new class is attached as an attribute to the JUnitWriter class, in
such a way that it has the same interface, and some attributes are moved
to this new class since they're only needed there. This has the
advantage of making the JUnitBackend class simpler, and makes the
writing easier to test, it will also be used in a follow up patch to
implement a different class that supports subtests.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Acked-by: Jose Fonseca <jfonseca@vmware.com> (v1)
Reviewed-by: Mark Janes <mark.a.janes@intel.com>
Tested-by: Mark Janes <mark.a.janes@intel.com>
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/framework/backends/test_junit.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/unittests/framework/backends/test_junit.py b/unittests/framework/backends/test_junit.py index a8443db19..8f09dac16 100644 --- a/unittests/framework/backends/test_junit.py +++ b/unittests/framework/backends/test_junit.py @@ -189,31 +189,32 @@ class TestJUnitBackend(object): test.finalize() - class TestWriteTest(object): - """Tests for the write_test method.""" - def test_junit_replace(self, tmpdir): - """backends.junit.JUnitBackend.write_test: grouptools.SEPARATOR is - replaced with '.'. - """ - result = results.TestResult() - result.time.end = 1.2345 - result.result = 'pass' - result.out = 'this is stdout' - result.err = 'this is stderr' - result.command = 'foo' +class TestJUnitWriter(object): + """Tests for the JUnitWriter class.""" - test = backends.junit.JUnitBackend(six.text_type(tmpdir)) - test.initialize(shared.INITIAL_METADATA) - with test.write_test(grouptools.join('a', 'group', 'test1')) as t: - t(result) - test.finalize() - - test_value = etree.parse(six.text_type(tmpdir.join('results.xml'))) - test_value = test_value.getroot() - - assert test_value.find('.//testcase').attrib['classname'] == \ - 'piglit.a.group' + def test_junit_replace(self, tmpdir): + """backends.junit.JUnitBackend.write_test: grouptools.SEPARATOR is + replaced with '.'. + """ + result = results.TestResult() + result.time.end = 1.2345 + result.result = 'pass' + result.out = 'this is stdout' + result.err = 'this is stderr' + result.command = 'foo' + + test = backends.junit.JUnitBackend(six.text_type(tmpdir)) + test.initialize(shared.INITIAL_METADATA) + with test.write_test(grouptools.join('a', 'group', 'test1')) as t: + t(result) + test.finalize() + + test_value = etree.parse(six.text_type(tmpdir.join('results.xml'))) + test_value = test_value.getroot() + + assert test_value.find('.//testcase').attrib['classname'] == \ + 'piglit.a.group' class TestValid(object): @pytest.fixture |