From 84fd77a2a57bbc7532165a384bfea7accf61c0c6 Mon Sep 17 00:00:00 2001 From: Carl Baillargeon Date: Mon, 24 Feb 2025 07:44:08 -0500 Subject: [PATCH] Fix unit tests for Windows --- anta/_runner.py | 2 +- tests/units/test__runner.py | 2 ++ tests/units/test_runner.py | 1 + tests/units/test_settings.py | 1 - 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/anta/_runner.py b/anta/_runner.py index f511b0938..712cfc91e 100644 --- a/anta/_runner.py +++ b/anta/_runner.py @@ -413,7 +413,7 @@ def _log_run_information(self, *, dry_run: bool = False) -> None: msg = "The inventory stats are not available. ANTA must be executed through AntaRunner.run()" raise RuntimeError(msg) - width = min(int(console.width) - 34, len(" Total potential connections: Unlimited\n")) + width = min(int(console.width) - 34, len(" Total potential connections: 100000000\n")) # Build device information device_lines = [ diff --git a/tests/units/test__runner.py b/tests/units/test__runner.py index f6f1ed294..0c82a6dd6 100644 --- a/tests/units/test__runner.py +++ b/tests/units/test__runner.py @@ -6,6 +6,7 @@ from __future__ import annotations import logging +import os import pytest from pydantic import ValidationError @@ -297,6 +298,7 @@ async def test_log_run_information_concurrency_limit(self, caplog: pytest.LogCap warning = "Tests count (27) exceeds concurrent limit (20). Tests will be throttled." assert warning in caplog.text + @pytest.mark.skipif(os.name != "posix", reason="Veriy unlikely to happen on non-POSIX systems due to sys.maxsize") @pytest.mark.parametrize(("anta_runner"), [{"inventory": "test_inventory_with_tags.yml", "catalog": "test_catalog_with_tags.yml", "nofile": 128}], indirect=True) async def test_log_run_information_file_descriptor_limit(self, caplog: pytest.LogCaptureFixture, anta_runner: AntaRunner) -> None: """Test _log_run_information with higher connections count than file descriptor limit.""" diff --git a/tests/units/test_runner.py b/tests/units/test_runner.py index d96fce17e..6d8de26ae 100644 --- a/tests/units/test_runner.py +++ b/tests/units/test_runner.py @@ -191,6 +191,7 @@ async def test_check_runner_log_for_windows_fake(caplog: pytest.LogCaptureFixtur assert "Running on a non-POSIX system, cannot adjust the maximum number of file descriptors." in caplog.records[0].message +# TODO: Remove this in ANTA v2.0.0 @pytest.mark.filterwarnings("ignore::DeprecationWarning") @pytest.mark.parametrize( ("inventory", "tags", "tests", "devices_count", "tests_count"), diff --git a/tests/units/test_settings.py b/tests/units/test_settings.py index 4408b64d3..e8640ca33 100644 --- a/tests/units/test_settings.py +++ b/tests/units/test_settings.py @@ -38,7 +38,6 @@ def test_env_var(self, setenvvar: pytest.MonkeyPatch) -> None: setenvvar.setenv("ANTA_SCHEDULING_TESTS_PER_DEVICE", "50") settings = AntaRunnerSettings() assert settings.nofile == 20480 - assert settings.file_descriptor_limit == 20480 assert settings.scheduling_strategy == "device-by-device" assert settings.scheduling_tests_per_device == 50 assert settings.max_concurrency == DEFAULT_MAX_CONCURRENCY