From a4b7a39aec7f325fe36846850fc538672428f496 Mon Sep 17 00:00:00 2001 From: Cody Baker Date: Fri, 30 Jan 2026 13:34:35 -0500 Subject: [PATCH 1/2] better error on unsupported systems --- src/con_duct/_sampling.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/con_duct/_sampling.py b/src/con_duct/_sampling.py index eac832ce..caa90517 100644 --- a/src/con_duct/_sampling.py +++ b/src/con_duct/_sampling.py @@ -7,11 +7,22 @@ import os import platform import subprocess +import sys from typing import Callable, Optional from con_duct._models import Averages, ProcessStats, Sample SYSTEM = platform.system() +_SUPPORTED_SYSTEMS = {"Linux", "Darwin"} +if SYSTEM not in _SUPPORTED_SYSTEMS: + sys.tracebacklimit = 0 + message = ( + f"`con_duct` does not currently support the detected operating system ({SYSTEM}).\n\n" + "If you would like to request support, please open an issue at: " + "https://github.com/con/duct/issues/new" + ) + raise NotImplementedError(message) + lgr = logging.getLogger("con-duct") From c736e91130f04b510ca2e94e6a6c645f1c43d918 Mon Sep 17 00:00:00 2001 From: Austin Macdonald Date: Sat, 31 Jan 2026 10:58:31 -0600 Subject: [PATCH 2/2] test: add test for unsupported OS error at import time Co-Authored-By: Claude Opus 4.5 --- test/test_windows.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/test_windows.py diff --git a/test/test_windows.py b/test/test_windows.py new file mode 100644 index 00000000..5352e3f0 --- /dev/null +++ b/test/test_windows.py @@ -0,0 +1,28 @@ +from __future__ import annotations +import importlib +import sys +from typing import Generator +from unittest import mock +import pytest + + +@pytest.fixture +def _reload_sampling() -> Generator: + """Ensure _sampling module is restored after tests that reload it.""" + import con_duct._sampling as mod + + yield + if hasattr(sys, "tracebacklimit"): + del sys.tracebacklimit + importlib.reload(mod) + + +@mock.patch("platform.system", return_value="Windows") +@pytest.mark.usefixtures("_reload_sampling") +def test_unsupported_system_raises(_mock_system: mock.MagicMock) -> None: + import con_duct._sampling as mod + + with pytest.raises( + NotImplementedError, match="does not currently support.*Windows" + ): + importlib.reload(mod)