[diffoscope] 04/05: Misc style fixups to XML comparator.

Chris Lamb chris at chris-lamb.co.uk
Fri Jul 21 11:43:56 CEST 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 9123eb091c49db4d7685e36d33f539bcbecefae1
Author: Chris Lamb <lamby at debian.org>
Date:   Fri Jul 21 10:35:25 2017 +0100

    Misc style fixups to XML comparator.
    
    Gbp-Dch: ignore
---
 diffoscope/comparators/xml.py | 19 +++++++++++++------
 tests/comparators/test_xml.py |  8 +++++---
 2 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/diffoscope/comparators/xml.py b/diffoscope/comparators/xml.py
index 6a5a6e9..bb6177c 100644
--- a/diffoscope/comparators/xml.py
+++ b/diffoscope/comparators/xml.py
@@ -20,9 +20,11 @@
 import re
 
 from xml.dom import minidom
+from xml.parsers.expat import ExpatError
+
 from diffoscope.difference import Difference
 from diffoscope.comparators.utils.file import File
-from xml.parsers.expat import ExpatError
+
 
 def _format(node):
     """
@@ -36,10 +38,12 @@ def _format(node):
     """
     for n in node.childNodes:
         if n.nodeType == minidom.Node.TEXT_NODE:
-            if n.nodeValue: n.nodeValue = n.nodeValue.strip()
+            if n.nodeValue:
+                n.nodeValue = n.nodeValue.strip()
         elif n.nodeType == minidom.Node.ELEMENT_NODE:
             _format(n)
 
+
 def _parse(file):
     """
     Formats a minidom.Document file and returns XML as string.
@@ -53,6 +57,7 @@ def _parse(file):
     xml = minidom.parse(file)
     _format(xml)
     xml.normalize()
+
     return xml.toprettyxml(indent=2*' ')
 
 
@@ -98,8 +103,12 @@ class XMLFile(File):
         Returns:
             A diffoscope.difference.Difference object
         """
-        return [ Difference.from_text(self.dumps(self), self.dumps(other),
-            self.path, other.path)]
+        return [Difference.from_text(
+            self.dumps(self),
+            self.dumps(other),
+            self.path,
+            other.path,
+        )]
 
     def dumps(self, file):
         """
@@ -116,5 +125,3 @@ class XMLFile(File):
 
         with open(file.path) as f:
             return _parse(f)
-
-
diff --git a/tests/comparators/test_xml.py b/tests/comparators/test_xml.py
index b77b06b..37924e1 100644
--- a/tests/comparators/test_xml.py
+++ b/tests/comparators/test_xml.py
@@ -22,28 +22,30 @@ import pytest
 from diffoscope.comparators.xml import XMLFile
 
 from ..utils.data import load_fixture, get_data
-from ..utils.nonexisting import assert_non_existing
 
 
 xml_a = load_fixture('test1.xml')
 xml_b = load_fixture('test2.xml')
 invalid_xml = load_fixture('test_invalid.xml')
 
+
 def test_identification(xml_a):
     assert isinstance(xml_a, XMLFile)
 
+
 def test_invalid(invalid_xml):
     assert not isinstance(invalid_xml, XMLFile)
 
+
 def test_no_differences(xml_a):
     assert xml_a.compare(xml_a) is None
 
+
 @pytest.fixture
 def differences(xml_a, xml_b):
     return xml_a.compare(xml_b).details
 
+
 def test_diff(differences):
     expected_diff = get_data('test_xml_expected_diff')
     assert differences[0].unified_diff == expected_diff
-
-

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list