mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 14:04:26 +08:00
inspect now raises OSError for objects without source file
CPython issue: https://bugs.python.org/issue44648
This commit is contained in:
committed by
Lumir Balhar
parent
1d944943c3
commit
eab1b8be8b
@@ -711,3 +711,24 @@ def test_negate():
|
||||
assert x.name == 'int'
|
||||
value, = x._name.infer()
|
||||
assert value.get_safe_value() == -3
|
||||
|
||||
|
||||
def test_complete_not_findable_class_source():
|
||||
class TestClass():
|
||||
ta=1
|
||||
ta1=2
|
||||
|
||||
# Simulate the environment where the class is defined in
|
||||
# an interactive session and therefore inspect module
|
||||
# cannot find its source code and raises OSError (Py 3.10+) or TypeError.
|
||||
TestClass.__module__ = "__main__"
|
||||
# There is a pytest __main__ module we have to remove temporarily.
|
||||
module = sys.modules.pop("__main__")
|
||||
try:
|
||||
interpreter = jedi.Interpreter("TestClass.", [locals()])
|
||||
completions = interpreter.complete(column=10, line=1)
|
||||
finally:
|
||||
sys.modules["__main__"] = module
|
||||
|
||||
assert "ta" in [c.name for c in completions]
|
||||
assert "ta1" in [c.name for c in completions]
|
||||
|
||||
Reference in New Issue
Block a user