Commits

Konstantine Rybnikov  committed 329323b

fix newline support (and test for that)

  • Participants
  • Parent commits 11f4363

Comments (0)

Files changed (2)

File fat_po_editor/diffutil.py

             
             def chunk(s, maxlen):
                 if len(s) > maxlen - 3:
-                    return u"".join([s[maxlen - 3], '...'])
+                    return u"".join([s[:maxlen - 3], '...'])
                 return s
-            
+
             return chunk(escape(s), maxlen)
         
         rv = StringBuilder()

File tests/test_diffutil.py

 
     def test_representation_too_long(self):
         diff = Diff()
-        entry = POEntry(msgid=u"First msgid",
+        entry = POEntry(msgid=u"F" * 81,
                         msgstr=u"First msgstr")
         diff.entry_append('add', entry)
 
         self.assertEquals(
             unicode(diff),
             (u"Added phrases:\n"
-             u"    * First msgid\n"))
+             u"    * %s...\n") % (u"F" * 71))
+
+    def test_representation_with_newline(self):
+        diff = Diff()
+        entry = POEntry(msgid=u"First \nmsgid",
+                        msgstr=u"First msgstr")
+        diff.entry_append('add', entry)
+
+        self.assertEquals(
+            unicode(diff),
+            (u"Added phrases:\n"
+             u"    * First \\nmsgid\n"))