diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-19 16:50:35 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2014-02-19 16:50:35 (GMT) |
commit | f6a38e11c061164eed35d2317a63a369c5f62818 (patch) | |
tree | 749875e7d7fa3e0f8d9abde09ad22537a50709c7 /Lib/test/test_tarfile.py | |
parent | 22234dab05f69fbbe2f906ab58f5abc95382f680 (diff) | |
parent | 162c477f41380d68d0e65e8b3921de86c6d0fbf7 (diff) | |
download | cpython-f6a38e11c061164eed35d2317a63a369c5f62818.zip cpython-f6a38e11c061164eed35d2317a63a369c5f62818.tar.gz cpython-f6a38e11c061164eed35d2317a63a369c5f62818.tar.bz2 |
Issue #20672: Fixed tests for TarFile.list() on non-UTF-8 locales.
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index ab88be4..92f8bfe 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -240,14 +240,16 @@ class ListTest(ReadTest, unittest.TestCase): self.assertIn(b'ustar/dirtype/', out) self.assertIn(b'ustar/dirtype-with-size/', out) # Make sure it is able to print unencodable characters - self.assertIn(br'ustar/umlauts-' - br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) - self.assertIn(br'misc/regtype-hpux-signed-chksum-' - br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) - self.assertIn(br'misc/regtype-old-v7-signed-chksum-' - br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) - self.assertIn(br'pax/bad-pax-\udce4\udcf6\udcfc', out) - self.assertIn(br'pax/hdrcharset-\udce4\udcf6\udcfc', out) + def conv(b): + s = b.decode(self.tar.encoding, 'surrogateescape') + return s.encode('ascii', 'backslashreplace') + self.assertIn(conv(b'ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) + self.assertIn(conv(b'misc/regtype-hpux-signed-chksum-' + b'\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) + self.assertIn(conv(b'misc/regtype-old-v7-signed-chksum-' + b'\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out) + self.assertIn(conv(b'pax/bad-pax-\xe4\xf6\xfc'), out) + self.assertIn(conv(b'pax/hdrcharset-\xe4\xf6\xfc'), out) # Make sure it prints files separated by one newline without any # 'ls -l'-like accessories if verbose flag is not being used # ... |