Skip to content

Commit

Permalink
Cope with io -> _io in Python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jun 23, 2023
1 parent 6b7dd8b commit e5bb8b4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/test_raw_building.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import tests.testdata.python3.data.fake_module_with_broken_getattr as fm_getattr
import tests.testdata.python3.data.fake_module_with_warnings as fm
from astroid.builder import AstroidBuilder
from astroid.const import IS_PYPY
from astroid.const import IS_PYPY, PY312_PLUS
from astroid.raw_building import (
attach_dummy_node,
build_class,
Expand Down Expand Up @@ -86,15 +86,16 @@ def test_build_from_import(self) -> None:

@unittest.skipIf(IS_PYPY, "Only affects CPython")
def test_io_is__io(self):
# _io module calls itself io. This leads
# _io module calls itself io before Python 3.12. This leads
# to cyclic dependencies when astroid tries to resolve
# what io.BufferedReader is. The code that handles this
# is in astroid.raw_building.imported_member, which verifies
# the true name of the module.
builder = AstroidBuilder()
module = builder.inspect_build(_io)
buffered_reader = module.getattr("BufferedReader")[0]
self.assertEqual(buffered_reader.root().name, "io")
expected = "_io" if PY312_PLUS else "io"
self.assertEqual(buffered_reader.root().name, expected)

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

0 comments on commit e5bb8b4

Please sign in to comment.