Download cpython_18/tests/private/eval_tests_aug.patch from lolbench26/LoLBench: direct link, hf CLI and curl.
- Browser
- Download file 3.07 kB
-
https://huggingface.co/datasets/lolbench26/LoLBench/resolve/main/cpython_18/tests/private/eval_tests_aug.patch
- Command line
-
hf download hf://datasets/lolbench26/LoLBench/cpython_18/tests/private/eval_tests_aug.patch
-
curl -L -o eval_tests_aug.patch https://huggingface.co/datasets/lolbench26/LoLBench/resolve/main/cpython_18/tests/private/eval_tests_aug.patch
3.07 kB
| diff --git a/Lib/test/test_capi/test_slots_aug.py b/Lib/test/test_capi/test_slots_aug.py | |
| new file mode 100644 | |
| index 0000000..cc199a7 | |
| --- /dev/null | |
| +++ b/Lib/test/test_capi/test_slots_aug.py | |
| +from test.support import import_helper | |
| +import unittest | |
| + | |
| +# See Modules/_testlimitedcapi/slots.c for the C definitions these tests drive. | |
| +# The augmented cases/helpers (token_use_spec, type_from_base_and_bases, | |
| +# module_from_slots_no_abi) are added by eval_tests_aug_helpers.patch. | |
| +_testlimitedcapi = import_helper.import_module('_testlimitedcapi') | |
| + | |
| + | |
| +class FakeSpec: | |
| + name = 'module' | |
| + | |
| + | |
| +class SlotsAugTests(unittest.TestCase): | |
| + """LoLBench augmented tests for PySlot behaviors not exercised by the | |
| + original test_slots suite. Each drives the public PySlot construction | |
| + surface (PyType_FromSlots / PyModule_FromSlotsAndSpec) through the | |
| + ``_testlimitedcapi`` helpers, asserting the documented validation rules. | |
| + """ | |
| + | |
| + def test_token_use_spec_requires_pytype_spec(self): | |
| + # PEP 820: with PyType_FromSlots the Py_tp_token slot may not be set to | |
| + # Py_TP_USE_SPEC (NULL) -- that sentinel only resolves under a | |
| + # PyType_Spec. The slots-only path must raise rather than silently | |
| + # build a type with a NULL token. | |
| + with self.assertRaisesRegex( | |
| + SystemError, "Py_TP_USE_SPEC"): | |
| + _testlimitedcapi.type_from_slots("token_use_spec") | |
| + | |
| + def test_tp_bases_overrides_tp_base(self): | |
| + # When both Py_tp_bases and Py_tp_base are supplied, Py_tp_bases wins | |
| + # (Py_tp_base is ignored once Py_tp_bases has been seen). | |
| + class A: | |
| + pass | |
| + | |
| + class B: | |
| + pass | |
| + | |
| + cls = _testlimitedcapi.type_from_base_and_bases((A,), B) | |
| + self.assertEqual(cls.__bases__, (A,)) | |
| + | |
| + def test_slots_only_module_requires_mod_abi(self): | |
| + # A module defined from slots only (no backing PyModuleDef) must declare | |
| + # Py_mod_abi; omitting it is a mandatory-slot SystemError. | |
| + with self.assertRaisesRegex( | |
| + SystemError, | |
| + ""): | |
| + _testlimitedcapi.module_from_slots_no_abi(FakeSpec()) | |
| + | |
| + | |
| +if __name__ == "__main__": | |
| + unittest.main() | |
| diff --git a/Lib/test/test_capi/test_slots_compat_aug.py b/Lib/test/test_capi/test_slots_compat_aug.py | |
| new file mode 100644 | |
| index 0000000..33060d6 | |
| --- /dev/null | |
| +++ b/Lib/test/test_capi/test_slots_compat_aug.py | |
| +import unittest | |
| + | |
| + | |
| +class SlotsCompatAugTests(unittest.TestCase): | |
| + """Augmented pass-to-pass guard: a stable type-construction contract that | |
| + is independent of the PySlot feature, so it passes both before and after | |
| + the solution is applied.""" | |
| + | |
| + def test_three_arg_type_construction_contract(self): | |
| + cls = type("C", (object,), {"x": 1}) | |
| + self.assertEqual(cls.__name__, "C") | |
| + self.assertEqual(cls.__bases__, (object,)) | |
| + self.assertEqual(cls().x, 1) | |
| + self.assertTrue(issubclass(cls, object)) | |
| + | |
| + | |
| +if __name__ == "__main__": | |
| + unittest.main() | |