Skip to main content

Pytest plugin to test the YLS as a whole.

Project description

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.

Project details


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.4.3.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pytest_yls-1.4.3-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_yls-1.4.3.tar.gz.

File metadata

  • Download URL: pytest_yls-1.4.3.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-45-generic

File hashes

Hashes for pytest_yls-1.4.3.tar.gz
Algorithm Hash digest
SHA256 9c04d479ed4333a95bb5548ebd54db2c45d5634348e8827e6787c8dc65e871ba
MD5 f67292a28471b447fb3f7c142d801600
BLAKE2b-256 fe0bf477c07a709bb4040e449f772310f7509e70b4e552ae1dfa669396ecad09

See more details on using hashes here.

File details

Details for the file pytest_yls-1.4.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_yls-1.4.3-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-45-generic

File hashes

Hashes for pytest_yls-1.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af073427d0dcbb9ee54d1f242cfcd699a32d6e6e8f49c64651664246f8b6b4f3
MD5 0c0ce4df96de539bb0e475a565833c70
BLAKE2b-256 c1a378d7c355512056b32a14c3ef37aaeaab86630a1e97c920ea24c966d0de54

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page