From 63076681872d8f1f34686e09c6625dee7cc50984 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 2 Nov 2025 17:16:07 +0000 Subject: [PATCH 1/4] Commit --- test_iconvcodec.py | 51 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/test_iconvcodec.py b/test_iconvcodec.py index aaa5bc9..24bcd65 100644 --- a/test_iconvcodec.py +++ b/test_iconvcodec.py @@ -5,9 +5,8 @@ class TestIconvcodecModule(unittest.TestCase): - @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_encode(self): - bytestring = "Hallo".encode("T.61") + bytestring = "Hallo".encode("Georgian-PS") self.assertEqual(bytestring, b"Hallo") def test_encode_with_long_out(self): @@ -18,9 +17,8 @@ def test_encode_with_long_out(self): else: self.assertEqual(bytestring, b"TM") - @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") def test_decode(self): - string = b"Hallo".decode("T.61") + string = b"Hallo".decode("Georgian-PS") self.assertEqual(string, "Hallo") @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") @@ -45,3 +43,48 @@ def test_incremental_decode(self): self.assertEqual(first, "") self.assertEqual(second, "\u0141") + + def test_available_encodings(self): + # Some from the list on https://www.gnu.org/software/libiconv/ + encodings = ( + *[f"ISO-8859-{i}" for i in (1, 2, 3, 4, 5, 7, 9, 10, 13, 14, 15, 16)], + *[ + f"CP{i}" + for i in ( + 437, + 737, + 775, + 852, + 855, + 857, + 858, + 860, + 861, + 862, + 863, + 865, + 869, + 1125, + 1133, + 1250, + 1251, + 1252, + 1253, + 1254, + 1257, + ) + ], + "Georgian-PS", + "ARMSCII-8", + "KOI8-T", + "PT154", + "RK1048", + "VISCII", + "TCVN", + "Macintosh", + ) + for encoding in encodings: + with self.subTest(encoding=encoding): + codec_info = iconvcodec.lookup(encoding) + if codec_info is None: + self.fail(f"Unsupported codec: '{encoding}'") From 8a2260065340408b9e2db6b196e4d6df04bc03fe Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 2 Nov 2025 17:16:27 +0000 Subject: [PATCH 2/4] Commit --- test_iconvcodec.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_iconvcodec.py b/test_iconvcodec.py index 24bcd65..3504ea0 100644 --- a/test_iconvcodec.py +++ b/test_iconvcodec.py @@ -47,7 +47,7 @@ def test_incremental_decode(self): def test_available_encodings(self): # Some from the list on https://www.gnu.org/software/libiconv/ encodings = ( - *[f"ISO-8859-{i}" for i in (1, 2, 3, 4, 5, 7, 9, 10, 13, 14, 15, 16)], + *[f"ISO-8859-{i}" for i in (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 13, 14, 15, 16)], *[ f"CP{i}" for i in ( From d06223a5a126d56c68c469ca15c95da6bc996d30 Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 2 Nov 2025 17:20:19 +0000 Subject: [PATCH 3/4] Debug --- test_iconvcodec.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test_iconvcodec.py b/test_iconvcodec.py index 3504ea0..7672e08 100644 --- a/test_iconvcodec.py +++ b/test_iconvcodec.py @@ -88,3 +88,10 @@ def test_available_encodings(self): codec_info = iconvcodec.lookup(encoding) if codec_info is None: self.fail(f"Unsupported codec: '{encoding}'") + # Actually test that encoding works + try: + "a".encode(encoding) + except Exception as e: + raise AssertionError( + f"Codec lookup succeeded but encode failed for '{encoding}'" + ) from None From b003edf9c9e7bb4fad14881283443bb92138394d Mon Sep 17 00:00:00 2001 From: Stan Ulbrych Date: Sun, 2 Nov 2025 17:24:49 +0000 Subject: [PATCH 4/4] Debug --- test_iconvcodec.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test_iconvcodec.py b/test_iconvcodec.py index 7672e08..97d206c 100644 --- a/test_iconvcodec.py +++ b/test_iconvcodec.py @@ -6,7 +6,7 @@ class TestIconvcodecModule(unittest.TestCase): def test_encode(self): - bytestring = "Hallo".encode("Georgian-PS") + bytestring = "Hallo".encode("VISCII") self.assertEqual(bytestring, b"Hallo") def test_encode_with_long_out(self): @@ -18,7 +18,7 @@ def test_encode_with_long_out(self): self.assertEqual(bytestring, b"TM") def test_decode(self): - string = b"Hallo".decode("Georgian-PS") + string = b"Hallo".decode("VISCII") self.assertEqual(string, "Hallo") @unittest.skipUnless(sys.platform.startswith("linux"), "Linux only test") @@ -74,8 +74,8 @@ def test_available_encodings(self): 1257, ) ], - "Georgian-PS", - "ARMSCII-8", + # "Georgian-PS", + # "ARMSCII-8", "KOI8-T", "PT154", "RK1048",