Pytest plugin to test the YLS as a whole.
Project description
pytest-yls
Pytest plugin adding primitives for E2E/integration tests.
Public fixtures:
yls_prepare
yls_prepare_with_settings
To interact with the tested YLS use Context
obtained by calling the fixture.
For more information about the Context
class checkout
plugin.py.
Example test
# Add yls_prepare fixture
def test_completion_basic(yls_prepare):
# Prepare the tested file
# <$> marks the cursor position
contents = """rule test {
condition:
<$>
}"""
# Initialize the testing context by calling the fixture
context = yls_prepare(contents)
# You can now simulate requests on the context
# In this case we trigger the code completion
response = context.send_request(
methods.COMPLETION,
types.CompletionParams(
textDocument=types.TextDocumentIdentifier(uri=context.opened_file.as_uri()),
position=context.get_cursor_position(),
),
)
# Assert the response how you want
assert response
for module in ["cuckoo", "elf", "pe", "time"]:
assert any(
module in item["label"] for item in response["items"]
), f"{module=} is not in response"
For more inspiration check out yls/tests.
License
Copyright (c) 2022 Avast Software, licensed under the MIT license. See the
LICENSE
file
for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytest_yls-1.2.5.tar.gz
(6.6 kB
view hashes)
Built Distribution
Close
Hashes for pytest_yls-1.2.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98d4213bb5c8b56f81369782babfc0a52df4be4e9c33b746f8b819c5bd72c4a4 |
|
MD5 | 157cb6b7725f9981930b610b1db20723 |
|
BLAKE2b-256 | 0e4e1b01de7645b14a61de9b7cefc1f6ffcdbe10dfaebdd1dabe03c1ea730bc1 |