Skip to content

Commit

Permalink
Add test for code completion
Browse files Browse the repository at this point in the history
  • Loading branch information
yukinarit committed May 31, 2024
1 parent fb95327 commit 912feda
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pytest-xdist = "^3.5.0"
types-PyYAML = "^6.0.9"
msgpack-types = "^0.3"
envclasses = "^0.3.1"
jedi = "*"

[tool.poetry.extras]
msgpack = ["msgpack"]
Expand Down
23 changes: 23 additions & 0 deletions tests/test_code_completion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import jedi


def test_jedi() -> None:
source = """
from serde import serde
@serde
class Foo:
a: int
b: float
c: str
baz: bool
foo = Foo(10, 100.0, "foo", True)
"""
source_completion = source + "\n" + "foo."
jedi_script = jedi.Script(source_completion, path="foo.py")
completions = jedi_script.complete(9, len("foo."))
completions = [comp.name for comp in completions]
assert "a" in completions
assert "b" in completions
assert "c" in completions

0 comments on commit 912feda

Please sign in to comment.