Exemplo n.º 1
0
 def test_encoding(self):
     content_old = (
         "lineö1\n".encode("utf-8")
     )
     content_new = (
         "lineö1\n".encode("latin-1")
     )
     self.assertEqual(
         files.diff(content_old, content_new, "/foo", encoding_hint="latin-1"),
         (
             red("--- /foo") + "\n" +
             green("+++ <blockwart content>") + "\n" +
             "@@ -1 +1 @@\n" +
             red("-lineö1") + "\n" +
             green("+lineö1") + " (line encoded in latin-1)\n"
         ),
     )
Exemplo n.º 2
0
 def test_long_line(self):
     content_old = (
         "line1\n"
     )
     content_new = (
         "line1" + 500 * "1" + "\n"
     )
     self.assertEqual(
         files.diff(content_old, content_new, "/foo"),
         (
             red("--- /foo") + "\n" +
             green("+++ <blockwart content>") + "\n" +
             "@@ -1 +1 @@\n" +
             red("-line1") + "\n" +
             green("+line111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") +
             " (line truncated after 128 characters)\n"
         ),
     )
Exemplo n.º 3
0
 def test_diff(self):
     content_old = (
         "line1\n"
         "line2\n"
     )
     content_new = (
         "line1\n"
         "line3\n"
     )
     self.assertEqual(
         files.diff(content_old, content_new, "/foo"),
         (
             red("--- /foo") + "\n" +
             green("+++ <blockwart content>") + "\n" +
             "@@ -1,2 +1,2 @@\n"
             " line1\n" +
             red("-line2") + "\n" +
             green("+line3") + "\n"
         ),
     )