diff --git a/doc/changelog.d/4725.test.md b/doc/changelog.d/4725.test.md new file mode 100644 index 000000000000..e3eb0280ce79 --- /dev/null +++ b/doc/changelog.d/4725.test.md @@ -0,0 +1 @@ +Add first intellisense test diff --git a/pyproject.toml b/pyproject.toml index 76dbec2b9d0e..51d851bdc43b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,7 +48,8 @@ tests = [ "pytest-cov==7.0.0", "pytest-mock==3.15.1", "pytest-xdist==3.8.0", - "pyfakefs==5.10.1" + "pyfakefs==5.10.1", + "jedi==0.19.2", ] docs = [ "Sphinx==8.1.3", diff --git a/tests/test_intellisense.py b/tests/test_intellisense.py new file mode 100644 index 000000000000..a8cfb54d0562 --- /dev/null +++ b/tests/test_intellisense.py @@ -0,0 +1,35 @@ +import jedi + + +def test_settings_file_read_case(): + prefix = """import ansys.fluent.core as pyfluent + solver = pyfluent.launch_fluent() + """ + path = "solver.settings." + filename = "example.py" + line = 4 + script = jedi.Script(code=f"{prefix}\n{path}", path=filename) + completions = script.complete(line=line, column=len(path)) + file = next((c for c in completions if c.name == "file"), None) + assert file is not None + assert file.name == "file" + assert file.docstring() == "file(*args, **kwargs)" # not correct + + path += "file." + script = jedi.Script(code=f"{prefix}\n{path}", path=filename) + completions = script.complete(line=line, column=len(path)) + read_case = next((c for c in completions if c.name == "read_case"), None) + assert read_case is not None + assert read_case.name == "read_case" + assert ( + read_case.docstring() + == "read_case(file_name: str, pdf_file_name: str)\n\n'read_case' command." + ) + + path += "read_case(" + script = jedi.Script(code=f"{prefix}\n{path}", path=filename) + completions = script.complete(line=line, column=len(path)) + file_name = next((c for c in completions if c.name == "file_name="), None) + assert file_name is not None + assert file_name.name == "file_name=" + assert file_name.docstring() == "" # not correct