Issue #20672: Fixed tests for TarFile.list() on non-UTF-8 locales.

This commit is contained in:
Serhiy Storchaka 2014-02-19 18:44:12 +02:00
parent e95977621d
commit 162c477f41
1 changed files with 10 additions and 8 deletions

View File

@ -238,14 +238,16 @@ class ListTest(ReadTest, unittest.TestCase):
self.assertIn(b'ustar/dirtype/', out) self.assertIn(b'ustar/dirtype/', out)
self.assertIn(b'ustar/dirtype-with-size/', out) self.assertIn(b'ustar/dirtype-with-size/', out)
# Make sure it is able to print unencodable characters # Make sure it is able to print unencodable characters
self.assertIn(br'ustar/umlauts-' def conv(b):
br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) s = b.decode(self.tar.encoding, 'surrogateescape')
self.assertIn(br'misc/regtype-hpux-signed-chksum-' return s.encode('ascii', 'backslashreplace')
br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) self.assertIn(conv(b'ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out)
self.assertIn(br'misc/regtype-old-v7-signed-chksum-' self.assertIn(conv(b'misc/regtype-hpux-signed-chksum-'
br'\udcc4\udcd6\udcdc\udce4\udcf6\udcfc\udcdf', out) b'\xc4\xd6\xdc\xe4\xf6\xfc\xdf'), out)
self.assertIn(br'pax/bad-pax-\udce4\udcf6\udcfc', out) self.assertIn(conv(b'misc/regtype-old-v7-signed-chksum-'
self.assertIn(br'pax/hdrcharset-\udce4\udcf6\udcfc', out) 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 # Make sure it prints files separated by one newline without any
# 'ls -l'-like accessories if verbose flag is not being used # 'ls -l'-like accessories if verbose flag is not being used
# ... # ...