From db344251c834e3aa682ecf7dfb3e52aa7b7ac4c4 Mon Sep 17 00:00:00 2001 From: Bhumika-1432006 Date: Tue, 13 Oct 2026 13:53:00 +0530 Subject: [PATCH 1/3] gh-131178: Add tests for `encodings.rot_13` command-line interface Add `Rot13CommandLineTest` class to `Lib/test/test_codecs.py` with subprocess-based tests for `python -m encodings.rot_13`. --- Lib/test/test_codecs.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 37ac57063c3539..5a8dcaf24f5504 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -4338,5 +4338,30 @@ def test_cache_bounded(self): self.assertLessEqual(len(encodings._cache), encodings._MAXCACHE) +@support.requires_subprocess() +class Rot13CommandLineTest(unittest.TestCase): + """Tests for the encodings.rot_13 command-line interface.""" + + def run_rot13(self, input_data): + from test.support.script_helper import spawn_python + with spawn_python('-m', 'encodings.rot_13') as proc: + out, err = proc.communicate(input_data.encode()) + return out.decode() + + def test_stdin_to_stdout(self): + result = self.run_rot13('Hello World') + self.assertEqual(result, 'Uryyb Jbeyq') + + def test_rot13_is_own_inverse(self): + plaintext = 'To be, or not to be, that is the question' + encoded = self.run_rot13(plaintext) + decoded = self.run_rot13(encoded) + self.assertEqual(decoded, plaintext) + + def test_non_alpha_unchanged(self): + result = self.run_rot13('Hello, World! 123') + self.assertEqual(result, 'Uryyb, Jbeyq! 123') + + if __name__ == "__main__": unittest.main() From ff77d95991ae711aade3326831c07979421f1b4c Mon Sep 17 00:00:00 2001 From: Bhumika-1432006 Date: Tue, 13 Oct 2026 14:52:03 +0530 Subject: [PATCH 2/3] gh-131178: Add NEWS entry for encodings.rot_13 CLI tests --- .../next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst diff --git a/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst b/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst new file mode 100644 index 00000000000000..3f8371d0a3d851 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst @@ -0,0 +1 @@ +Add tests for :mod:`encodings.rot_13` command-line interface. From 7e846588e4c443696f578097a50d381c7fd532f1 Mon Sep 17 00:00:00 2001 From: Bhumika-1432006 Date: Tue, 13 Oct 2026 19:32:28 +0530 Subject: [PATCH 3/3] gh-131178: Fix NEWS entry to use inline code instead of mod role --- .../next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst b/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst index 3f8371d0a3d851..7dc2c3c01efdba 100644 --- a/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst +++ b/Misc/NEWS.d/next/Tests/2026-10-13-00-00-00.gh-issue-131178.mlMLJXT.rst @@ -1 +1 @@ -Add tests for :mod:`encodings.rot_13` command-line interface. +Add tests for ``encodings.rot_13`` command-line interface.