Skip to content

Commit

Permalink
Fix unit tests for Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
carl-baillargeon committed Feb 24, 2025
1 parent e25826e commit 84fd77a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion anta/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions tests/units/test__runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import logging
import os

import pytest
from pydantic import ValidationError
Expand Down Expand Up @@ -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."""
Expand Down
1 change: 1 addition & 0 deletions tests/units/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion tests/units/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 84fd77a

Please sign in to comment.