Luke Ross

lxmlmeld

6 releases git clone https://lukeross.name/projects/lxmlmeld.git/

Meld-like templating using lxml.

Commit e692e013cbd7ed6ac53f571ec885a766a98b7c38

PEP8

Committed 15 Mar 2017 by Luke Ross & Luke Ross

tests/test_calls.py

@@ -7,26 +7,36 @@ class ReplaceTests(TestCase):
     def as_expected(self, arg, expected_in_output, **kwargs):
         docs = (
             (  # Naked
-                "<foo xmlns:meld='http://www.plope.com/software/meld3'><replaceme meld:id='r' /></foo>",
+                "<foo xmlns:meld='http://www.plope.com/software/meld3'>"
+                "<replaceme meld:id='r' /></foo>",
                 "<?xml version='1.0' encoding='ASCII'?>\n<foo>{}</foo>",
             ),
             (  # Surrounded by elements
-                "<foo xmlns:meld='http://www.plope.com/software/meld3'><bar /><replaceme meld:id='r' /><baz /></foo>",
-                "<?xml version='1.0' encoding='ASCII'?>\n<foo><bar/>{}<baz/></foo>",
+                "<foo xmlns:meld='http://www.plope.com/software/meld3'>"
+                "<bar /><replaceme meld:id='r' /><baz /></foo>",
+                "<?xml version='1.0' encoding='ASCII'?>\n"
+                "<foo><bar/>{}<baz/></foo>",
             ),
             (  # Surrounded by text
-                "<foo xmlns:meld='http://www.plope.com/software/meld3'>bar <replaceme meld:id='r' />baz</foo>",
+                "<foo xmlns:meld='http://www.plope.com/software/meld3'>"
+                "bar <replaceme meld:id='r' />baz</foo>",
                 "<?xml version='1.0' encoding='ASCII'?>\n<foo>bar {}baz</foo>",
             ),
             (  # Surrounded by mixed
-                "<foo xmlns:meld='http://www.plope.com/software/meld3'><bar />bar <replaceme meld:id='r' />baz</foo>",
-                "<?xml version='1.0' encoding='ASCII'?>\n<foo><bar/>bar {}baz</foo>",
+                "<foo xmlns:meld='http://www.plope.com/software/meld3'>"
+                "<bar />bar <replaceme meld:id='r' />baz</foo>",
+                "<?xml version='1.0' encoding='ASCII'?>\n"
+                "<foo><bar/>bar {}baz</foo>",
             ),
         )
         for ip, op in docs:
             doc = parse_xmlstring(ip)
             doc.findmeld("r").replace(arg, **kwargs)
-            self.assertEqual(doc.write_xmlstring(), op.format(expected_in_output).encode("ascii"), op.format(expected_in_output))
+            self.assertEqual(
+                doc.write_xmlstring(),
+                op.format(expected_in_output).encode("ascii"),
+                op.format(expected_in_output)
+            )
 
     def test_replace_with_plain_text(self):
         self.as_expected("<hello world!>", "&lt;hello world!&gt;")


tests/test_parsing.py

@@ -7,9 +7,18 @@ from lxmlmeld import parse_xml, parse_xmlstring
 class XMLTests(TestCase):
     def as_expected(self, handler):
         scenarios = (
-            ("<xml />", "<?xml version='1.0' encoding='ASCII'?>\n<xml/>"),
-            ("<?xml version='1.0' ?><xml />", "<?xml version='1.0' encoding='ASCII'?>\n<xml/>"),
-            ("<xml><a /><b /></xml>", "<?xml version='1.0' encoding='ASCII'?>\n<xml><a/><b/></xml>"),
+            (
+                "<xml />",
+                "<?xml version='1.0' encoding='ASCII'?>\n<xml/>"
+            ),
+            (
+                "<?xml version='1.0' ?><xml />",
+                "<?xml version='1.0' encoding='ASCII'?>\n<xml/>"
+            ),
+            (
+                "<xml><a /><b /></xml>",
+                "<?xml version='1.0' encoding='ASCII'?>\n<xml><a/><b/></xml>"
+            ),
         )
         for ip, op in scenarios:
             doc = handler(ip)