| Name | pytest-yls JSON |
| Version |
1.4.3
JSON |
| download |
| home_page | None |
| Summary | Pytest plugin to test the YLS as a whole. |
| upload_time | 2024-10-18 15:25:10 |
| maintainer | Matej Kašťák |
| docs_url | None |
| author | Matej Kastak |
| requires_python | <4.0,>=3.8 |
| license | MIT |
| keywords |
|
| VCS |
|
| bugtrack_url |
|
| requirements |
No requirements were recorded.
|
| Travis-CI |
No Travis.
|
| coveralls test coverage |
No coveralls.
|
# 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](https://github.com/avast/yls/blob/master/pytest-yls/pytest_yls/plugin.py).
### Example test
```python
# 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](https://github.com/avast/yls/tree/master/tests).
## License
Copyright (c) 2022 Avast Software, licensed under the MIT license. See the
[`LICENSE`](https://github.com/avast/yls/blob/master/pytest-yls/LICENSE) file
for more details.
Raw data
{
"_id": null,
"home_page": null,
"name": "pytest-yls",
"maintainer": "Matej Ka\u0161\u0165\u00e1k",
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": "matej.kastak@avast.com",
"keywords": null,
"author": "Matej Kastak",
"author_email": "matej.kastak@avast.com",
"download_url": "https://files.pythonhosted.org/packages/fe/0b/f477c07a709bb4040e449f772310f7509e70b4e552ae1dfa669396ecad09/pytest_yls-1.4.3.tar.gz",
"platform": null,
"description": "# pytest-yls\n\n\n\nPytest plugin adding primitives for E2E/integration tests.\n\nPublic fixtures:\n- `yls_prepare`\n- `yls_prepare_with_settings`\n\nTo interact with the tested YLS use `Context` obtained by calling the fixture.\nFor more information about the `Context` class checkout\n[plugin.py](https://github.com/avast/yls/blob/master/pytest-yls/pytest_yls/plugin.py).\n\n### Example test\n\n```python\n\n# Add yls_prepare fixture\ndef test_completion_basic(yls_prepare):\n # Prepare the tested file\n # <$> marks the cursor position\n contents = \"\"\"rule test {\n condition:\n <$>\n}\"\"\"\n \n # Initialize the testing context by calling the fixture\n context = yls_prepare(contents)\n\n # You can now simulate requests on the context\n # In this case we trigger the code completion\n response = context.send_request(\n methods.COMPLETION,\n types.CompletionParams(\n textDocument=types.TextDocumentIdentifier(uri=context.opened_file.as_uri()),\n position=context.get_cursor_position(),\n ),\n )\n\n # Assert the response how you want\n assert response\n for module in [\"cuckoo\", \"elf\", \"pe\", \"time\"]:\n assert any(\n module in item[\"label\"] for item in response[\"items\"]\n ), f\"{module=} is not in response\"\n```\n\nFor more inspiration check out\n[yls/tests](https://github.com/avast/yls/tree/master/tests).\n\n## License\n\nCopyright (c) 2022 Avast Software, licensed under the MIT license. See the\n[`LICENSE`](https://github.com/avast/yls/blob/master/pytest-yls/LICENSE) file\nfor more details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pytest plugin to test the YLS as a whole.",
"version": "1.4.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c1a378d7c355512056b32a14c3ef37aaeaab86630a1e97c920ea24c966d0de54",
"md5": "0c0ce4df96de539bb0e475a565833c70",
"sha256": "af073427d0dcbb9ee54d1f242cfcd699a32d6e6e8f49c64651664246f8b6b4f3"
},
"downloads": -1,
"filename": "pytest_yls-1.4.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c0ce4df96de539bb0e475a565833c70",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 8108,
"upload_time": "2024-10-18T15:25:09",
"upload_time_iso_8601": "2024-10-18T15:25:09.876586Z",
"url": "https://files.pythonhosted.org/packages/c1/a3/78d7c355512056b32a14c3ef37aaeaab86630a1e97c920ea24c966d0de54/pytest_yls-1.4.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fe0bf477c07a709bb4040e449f772310f7509e70b4e552ae1dfa669396ecad09",
"md5": "f67292a28471b447fb3f7c142d801600",
"sha256": "9c04d479ed4333a95bb5548ebd54db2c45d5634348e8827e6787c8dc65e871ba"
},
"downloads": -1,
"filename": "pytest_yls-1.4.3.tar.gz",
"has_sig": false,
"md5_digest": "f67292a28471b447fb3f7c142d801600",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 6021,
"upload_time": "2024-10-18T15:25:10",
"upload_time_iso_8601": "2024-10-18T15:25:10.884888Z",
"url": "https://files.pythonhosted.org/packages/fe/0b/f477c07a709bb4040e449f772310f7509e70b4e552ae1dfa669396ecad09/pytest_yls-1.4.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 15:25:10",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pytest-yls"
}