|
24 | 24 | import tests.testdata.python3.data.fake_module_with_broken_getattr as fm_getattr
|
25 | 25 | import tests.testdata.python3.data.fake_module_with_warnings as fm
|
26 | 26 | from astroid.builder import AstroidBuilder
|
27 |
| -from astroid.const import IS_PYPY |
| 27 | +from astroid.const import IS_PYPY, PY312_PLUS |
28 | 28 | from astroid.raw_building import (
|
29 | 29 | attach_dummy_node,
|
30 | 30 | build_class,
|
@@ -86,15 +86,16 @@ def test_build_from_import(self) -> None:
|
86 | 86 |
|
87 | 87 | @unittest.skipIf(IS_PYPY, "Only affects CPython")
|
88 | 88 | def test_io_is__io(self):
|
89 |
| - # _io module calls itself io. This leads |
| 89 | + # _io module calls itself io before Python 3.12. This leads |
90 | 90 | # to cyclic dependencies when astroid tries to resolve
|
91 | 91 | # what io.BufferedReader is. The code that handles this
|
92 | 92 | # is in astroid.raw_building.imported_member, which verifies
|
93 | 93 | # the true name of the module.
|
94 | 94 | builder = AstroidBuilder()
|
95 | 95 | module = builder.inspect_build(_io)
|
96 | 96 | buffered_reader = module.getattr("BufferedReader")[0]
|
97 |
| - self.assertEqual(buffered_reader.root().name, "io") |
| 97 | + expected = "_io" if PY312_PLUS else "io" |
| 98 | + self.assertEqual(buffered_reader.root().name, expected) |
98 | 99 |
|
99 | 100 | def test_build_function_deepinspect_deprecation(self) -> None:
|
100 | 101 | # Tests https://github.com/pylint-dev/astroid/issues/1717
|
|
0 commit comments