summaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 08:35:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 08:35:51 +0000
commit641d0d615623d4818993e1967fc96af1eefc4605 (patch)
treec40f205eb559c8a495489262190a0be4f1829740 /tests/conftest.py
parentAdding upstream version 0.13.0. (diff)
downloadanta-641d0d615623d4818993e1967fc96af1eefc4605.tar.xz
anta-641d0d615623d4818993e1967fc96af1eefc4605.zip
Adding upstream version 0.14.0.upstream/0.14.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index 5a40c24..7aa229c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,19 +1,15 @@
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
-"""
-conftest.py - used to store anta specific fixtures used for tests
-"""
+"""conftest.py - used to store anta specific fixtures used for tests."""
+
from __future__ import annotations
import logging
-from typing import TYPE_CHECKING, Any
+from typing import Any
import pytest
-if TYPE_CHECKING:
- from pytest import Metafunc
-
# Load fixtures from dedicated file tests/lib/fixture.py
# As well as pytest_asyncio plugin to test co-routines
pytest_plugins = [
@@ -31,8 +27,7 @@ for _ in ("asyncio", "httpx"):
def build_test_id(val: dict[str, Any]) -> str:
- """
- build id for a unit test of an AntaTest subclass
+ """Build id for a unit test of an AntaTest subclass.
{
"name": "meaniful test name",
@@ -43,9 +38,9 @@ def build_test_id(val: dict[str, Any]) -> str:
return f"{val['test'].__module__}.{val['test'].__name__}-{val['name']}"
-def pytest_generate_tests(metafunc: Metafunc) -> None:
- """
- This function is called during test collection.
+def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
+ """Generate ANTA testts unit tests dynamically during test collection.
+
It will parametrize test cases based on the `DATA` data structure defined in `tests.units.anta_tests` modules.
See `tests/units/anta_tests/README.md` for more information on how to use it.
Test IDs are generated using the `build_test_id` function above.