MCPcopy Create free account
hub / github.com/RustPython/RustPython / load_tests

Function load_tests

Lib/test/test_io.py:5121–5159  ·  view source on GitHub ↗
(loader, tests, pattern)

Source from the content-addressed store, hash-verified

5119
5120
5121def load_tests(loader, tests, pattern):
5122 tests = (CIOTest, PyIOTest, APIMismatchTest,
5123 CBufferedReaderTest, PyBufferedReaderTest,
5124 CBufferedWriterTest, PyBufferedWriterTest,
5125 CBufferedRWPairTest, PyBufferedRWPairTest,
5126 CBufferedRandomTest, PyBufferedRandomTest,
5127 StatefulIncrementalDecoderTest,
5128 CIncrementalNewlineDecoderTest, PyIncrementalNewlineDecoderTest,
5129 CTextIOWrapperTest, PyTextIOWrapperTest,
5130 CMiscIOTest, PyMiscIOTest,
5131 CSignalsTest, PySignalsTest, TestIOCTypes,
5132 ProtocolsTest,
5133 )
5134
5135 # Put the namespaces of the IO module we are testing and some useful mock
5136 # classes in the __dict__ of each test.
5137 mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
5138 MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead,
5139 SlowFlushRawIO, MockCharPseudoDevFileIO)
5140 all_members = io.__all__
5141 c_io_ns = {name : getattr(io, name) for name in all_members}
5142 py_io_ns = {name : getattr(pyio, name) for name in all_members}
5143 globs = globals()
5144 c_io_ns.update((x.__name__, globs["C" + x.__name__]) for x in mocks)
5145 py_io_ns.update((x.__name__, globs["Py" + x.__name__]) for x in mocks)
5146 for test in tests:
5147 if test.__name__.startswith("C"):
5148 for name, obj in c_io_ns.items():
5149 setattr(test, name, obj)
5150 test.is_C = True
5151 elif test.__name__.startswith("Py"):
5152 for name, obj in py_io_ns.items():
5153 setattr(test, name, obj)
5154 test.is_C = False
5155
5156 suite = loader.suiteClass()
5157 for test in tests:
5158 suite.addTest(loader.loadTestsFromTestCase(test))
5159 return suite
5160
5161if __name__ == "__main__":
5162 unittest.main()

Callers 1

loadTestsFromModuleMethod · 0.50

Calls 8

getattrFunction · 0.85
globalsFunction · 0.85
setattrFunction · 0.85
addTestMethod · 0.80
loadTestsFromTestCaseMethod · 0.80
updateMethod · 0.45
startswithMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected