From 1b16d649f9c43573111af19d29f34fa7330aff88 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Fri, 25 May 2018 18:21:48 -0300 Subject: [PATCH] Fix formatting of merged files --- _pytest/junitxml.py | 1 - changelog/3491.bugfix.rst | 2 +- testing/test_junitxml.py | 10 ++++++---- testing/test_unittest.py | 26 +++++++++++++++----------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py index 0fd466d06..29da27de7 100644 --- a/_pytest/junitxml.py +++ b/_pytest/junitxml.py @@ -233,7 +233,6 @@ class _NodeReporter(object): ) self.write_captured_output(report) - def finalize(self): data = self.to_xml().unicode(indent=0) self.__dict__.clear() diff --git a/changelog/3491.bugfix.rst b/changelog/3491.bugfix.rst index 2ac733cbc..4c2507b85 100644 --- a/changelog/3491.bugfix.rst +++ b/changelog/3491.bugfix.rst @@ -1 +1 @@ -Fixed a bug where stdout and stderr were logged twice by junitxml when a test was marked xfail. \ No newline at end of file +Fixed a bug where stdout and stderr were logged twice by junitxml when a test was marked xfail. diff --git a/testing/test_junitxml.py b/testing/test_junitxml.py index 6522abf13..d0be5f267 100644 --- a/testing/test_junitxml.py +++ b/testing/test_junitxml.py @@ -504,7 +504,8 @@ class TestPython(object): # assert "ValueError" in fnode.toxml() def test_xfail_captures_output_once(self, testdir): - testdir.makepyfile(""" + testdir.makepyfile( + """ import sys import pytest @@ -513,12 +514,13 @@ class TestPython(object): sys.stdout.write('XFAIL This is stdout') sys.stderr.write('XFAIL This is stderr') assert 0 - """) + """ + ) result, dom = runandparse(testdir) node = dom.find_first_by_tag("testsuite") tnode = node.find_first_by_tag("testcase") - assert len(tnode.find_by_tag('system-err')) == 1 - assert len(tnode.find_by_tag('system-out')) == 1 + assert len(tnode.find_by_tag("system-err")) == 1 + assert len(tnode.find_by_tag("system-out")) == 1 def test_xfailure_xpass(self, testdir): testdir.makepyfile( diff --git a/testing/test_unittest.py b/testing/test_unittest.py index f5728c781..65ffdb975 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -928,15 +928,14 @@ def test_class_method_containing_test_issue1558(testdir): @pytest.mark.issue(3498) -@pytest.mark.parametrize("base", [ - 'six.moves.builtins.object', - 'unittest.TestCase', - 'unittest2.TestCase', -]) +@pytest.mark.parametrize( + "base", ["six.moves.builtins.object", "unittest.TestCase", "unittest2.TestCase"] +) def test_usefixtures_marker_on_unittest(base, testdir): - module = base.rsplit('.', 1)[0] + module = base.rsplit(".", 1)[0] pytest.importorskip(module) - testdir.makepyfile(conftest=""" + testdir.makepyfile( + conftest=""" import pytest @pytest.fixture(scope='function') @@ -961,9 +960,11 @@ def test_usefixtures_marker_on_unittest(base, testdir): for item in items: node_and_marks(item) - """) + """ + ) - testdir.makepyfile(""" + testdir.makepyfile( + """ import pytest import {module} @@ -982,7 +983,10 @@ def test_usefixtures_marker_on_unittest(base, testdir): assert self.fixture2 - """.format(module=module, base=base)) + """.format( + module=module, base=base + ) + ) - result = testdir.runpytest('-s') + result = testdir.runpytest("-s") result.assert_outcomes(passed=2)