Skip to main content

pytest-yls

PyPI

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.

Release files for pytest-yls 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-yls 1.4.0
File Size Uploaded
pytest_yls-1.4.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-yls 1.4.0
File Interpreter ABI Platform
pytest_yls-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.2 kB

Release files / pytest_yls-1.4.0.tar.gz

Download URL pytest_yls-1.4.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1c07ae50205db2a051cf8e2fe6a043143f4dbc0473b07e72c0b5716a4aa17e20
BLAKE2b-256 checksum
How to use checksums
23045e1bda7c62829ccace4aa832aa5457246c89faa277c6eb5629d43b333687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-71-generic

Release files / pytest_yls-1.4.0-py3-none-any.whl

Download URL pytest_yls-1.4.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2a94fe93e11373611a270fa9679b8548e85b4254c079cc604a2147d659fb2979
BLAKE2b-256 checksum
How to use checksums
db44d29eb5783a25da81e392e77b8a054dfb8763139fafad0ad622fdc62ea9c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.12 Linux/5.15.0-71-generic

Release history Release notifications | RSS feed

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

This release

1.4.0 This release

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page