summaryrefslogtreecommitdiffstats
path: root/tests/units/test_runner.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/units/test_runner.py')
-rw-r--r--tests/units/test_runner.py38
1 files changed, 14 insertions, 24 deletions
diff --git a/tests/units/test_runner.py b/tests/units/test_runner.py
index c353cbe..d5bb892 100644
--- a/tests/units/test_runner.py
+++ b/tests/units/test_runner.py
@@ -1,13 +1,11 @@
# 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.
-"""
-test anta.runner.py
-"""
+"""test anta.runner.py."""
+
from __future__ import annotations
import logging
-from typing import TYPE_CHECKING
import pytest
@@ -19,16 +17,12 @@ from anta.runner import main
from .test_models import FakeTest
-if TYPE_CHECKING:
- from pytest import LogCaptureFixture
-
FAKE_CATALOG: AntaCatalog = AntaCatalog.from_list([(FakeTest, None)])
-@pytest.mark.asyncio
-async def test_runner_empty_tests(caplog: LogCaptureFixture, test_inventory: AntaInventory) -> None:
- """
- Test that when the list of tests is empty, a log is raised
+@pytest.mark.asyncio()
+async def test_runner_empty_tests(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None:
+ """Test that when the list of tests is empty, a log is raised.
caplog is the pytest fixture to capture logs
test_inventory is a fixture that gives a default inventory for tests
@@ -42,10 +36,9 @@ async def test_runner_empty_tests(caplog: LogCaptureFixture, test_inventory: Ant
assert "The list of tests is empty, exiting" in caplog.records[0].message
-@pytest.mark.asyncio
-async def test_runner_empty_inventory(caplog: LogCaptureFixture) -> None:
- """
- Test that when the Inventory is empty, a log is raised
+@pytest.mark.asyncio()
+async def test_runner_empty_inventory(caplog: pytest.LogCaptureFixture) -> None:
+ """Test that when the Inventory is empty, a log is raised.
caplog is the pytest fixture to capture logs
"""
@@ -58,10 +51,9 @@ async def test_runner_empty_inventory(caplog: LogCaptureFixture) -> None:
assert "The inventory is empty, exiting" in caplog.records[0].message
-@pytest.mark.asyncio
-async def test_runner_no_selected_device(caplog: LogCaptureFixture, test_inventory: AntaInventory) -> None:
- """
- Test that when the list of established device
+@pytest.mark.asyncio()
+async def test_runner_no_selected_device(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None:
+ """Test that when the list of established device.
caplog is the pytest fixture to capture logs
test_inventory is a fixture that gives a default inventory for tests
@@ -71,12 +63,10 @@ async def test_runner_no_selected_device(caplog: LogCaptureFixture, test_invento
manager = ResultManager()
await main(manager, test_inventory, FAKE_CATALOG)
- assert "No device in the established state 'True' was found. There is no device to run tests against, exiting" in [record.message for record in caplog.records]
+ assert "No reachable device was found." in [record.message for record in caplog.records]
# Reset logs and run with tags
caplog.clear()
- await main(manager, test_inventory, FAKE_CATALOG, tags=["toto"])
+ await main(manager, test_inventory, FAKE_CATALOG, tags={"toto"})
- assert "No device in the established state 'True' matching the tags ['toto'] was found. There is no device to run tests against, exiting" in [
- record.message for record in caplog.records
- ]
+ assert "No reachable device matching the tags {'toto'} was found." in [record.message for record in caplog.records]