From: Cody Maloney Date: Tue, 16 Sep 2025 08:37:28 +0000 (-0700) Subject: gh-138013: Remove load_tests in test_io.test_general (#138771) X-Git-Tag: v3.15.0a1~339 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ed75160b73ee850103ccc55d4124b16424b9c002;p=thirdparty%2FPython%2Fcpython.git gh-138013: Remove load_tests in test_io.test_general (#138771) Rely on default test discovery. Validation: ```bash # Run before commit ./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > old_cases.txt # Run after commit ./python -m test test_io -uall,walltime,largefile,cpu,extralargefile -M25G -o --fail-env-changed -j0 --list-cases | sort > new_cases.txt diff new_cases.txt old_cases. # ``` --- diff --git a/Lib/test/test_io/test_general.py b/Lib/test/test_io/test_general.py index c450f957ab69..c2f0e1877a69 100644 --- a/Lib/test/test_io/test_general.py +++ b/Lib/test/test_io/test_general.py @@ -49,7 +49,7 @@ class BadIndex: 1/0 -class IOTest(unittest.TestCase): +class IOTest: def setUp(self): os_helper.unlink(os_helper.TESTFN) @@ -2535,7 +2535,7 @@ class StatefulIncrementalDecoderTest(unittest.TestCase): self.assertEqual(d.decode(b'oiabcd'), '') self.assertEqual(d.decode(b'', 1), 'abcd.') -class TextIOWrapperTest(unittest.TestCase): +class TextIOWrapperTest: def setUp(self): self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n" @@ -3893,7 +3893,7 @@ class PyTextIOWrapperTest(TextIOWrapperTest, PyTestCase): shutdown_error = "LookupError: unknown encoding: ascii" -class IncrementalNewlineDecoderTest(unittest.TestCase): +class IncrementalNewlineDecoderTest: def check_newline_decoding_utf8(self, decoder): # UTF-8 specific tests for a newline decoder @@ -4010,7 +4010,7 @@ class IncrementalNewlineDecoderTest(unittest.TestCase): decoder = self.IncrementalNewlineDecoder(decoder, translate=0) self.assertEqual(decoder.decode(b"\r\r\n"), "\r\r\n") -class CIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest): +class CIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest, unittest.TestCase): IncrementalNewlineDecoder = io.IncrementalNewlineDecoder @support.cpython_only @@ -4023,13 +4023,13 @@ class CIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest): self.assertRaises(ValueError, uninitialized.reset) -class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest): +class PyIncrementalNewlineDecoderTest(IncrementalNewlineDecoderTest, unittest.TestCase): IncrementalNewlineDecoder = pyio.IncrementalNewlineDecoder # XXX Tests for open() -class MiscIOTest(unittest.TestCase): +class MiscIOTest: # for test__all__, actual values are set in subclasses name_of_module = None @@ -4465,7 +4465,7 @@ class PyMiscIOTest(MiscIOTest, PyTestCase): @unittest.skipIf(os.name == 'nt', 'POSIX signals required for this test.') -class SignalsTest(unittest.TestCase): +class SignalsTest: def setUp(self): self.oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt) @@ -4749,24 +4749,5 @@ class ProtocolsTest(unittest.TestCase): self.assertNotIsSubclass(str, io.Writer) -def load_tests(loader, tests, pattern): - tests = (CIOTest, PyIOTest, APIMismatchTest, - CBufferedReaderTest, PyBufferedReaderTest, - CBufferedWriterTest, PyBufferedWriterTest, - CBufferedRWPairTest, PyBufferedRWPairTest, - CBufferedRandomTest, PyBufferedRandomTest, - StatefulIncrementalDecoderTest, - CIncrementalNewlineDecoderTest, PyIncrementalNewlineDecoderTest, - CTextIOWrapperTest, PyTextIOWrapperTest, - CMiscIOTest, PyMiscIOTest, - CSignalsTest, PySignalsTest, TestIOCTypes, - ProtocolsTest, - ) - - suite = loader.suiteClass() - for test in tests: - suite.addTest(loader.loadTestsFromTestCase(test)) - return suite - if __name__ == "__main__": unittest.main()