Skip to content

Commit 54c65fc

Browse files
Cope with io -> _io in Python 3.12
1 parent 731efc3 commit 54c65fc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_raw_building.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import tests.testdata.python3.data.fake_module_with_broken_getattr as fm_getattr
2525
import tests.testdata.python3.data.fake_module_with_warnings as fm
2626
from astroid.builder import AstroidBuilder
27-
from astroid.const import IS_PYPY
27+
from astroid.const import IS_PYPY, PY312_PLUS
2828
from astroid.raw_building import (
2929
attach_dummy_node,
3030
build_class,
@@ -86,15 +86,16 @@ def test_build_from_import(self) -> None:
8686

8787
@unittest.skipIf(IS_PYPY, "Only affects CPython")
8888
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
9090
# to cyclic dependencies when astroid tries to resolve
9191
# what io.BufferedReader is. The code that handles this
9292
# is in astroid.raw_building.imported_member, which verifies
9393
# the true name of the module.
9494
builder = AstroidBuilder()
9595
module = builder.inspect_build(_io)
9696
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)
9899

99100
def test_build_function_deepinspect_deprecation(self) -> None:
100101
# Tests https://github.com/pylint-dev/astroid/issues/1717

0 commit comments

Comments
 (0)