def test_encoding_unknown(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="ascii"), ( red("--- /foo") + "\n" + green("+++ <bundlewrap content>") + "\n" + "@@ -1 +1 @@\n" + red("-lineö1") + "\n" + green("+") + " (line not encoded in UTF-8 or ascii)\n" ), )
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("+++ <bundlewrap content>") + "\n" + "@@ -1 +1 @@\n" + red("-lineö1") + "\n" + green("+line�1") + "\n" ), )
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("+++ <bundlewrap content>") + "\n" + "@@ -1 +1 @@\n" + red("-line1") + "\n" + green("+line111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111") + " (line truncated after 128 characters)\n" ), )
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("+++ <bundlewrap content>") + "\n" + "@@ -1,2 +1,2 @@\n" " line1\n" + red("-line2") + "\n" + green("+line3") + "\n" ), )