Skip to content

Commit 7c79f25

Browse files
committed
test(pathfinder): mark diagnostic log tests thread-unsafe; parse only decimal levels
Signed-off-by: Utkarsh Bahuguna <[email protected]>
1 parent 4c9b60e commit 7c79f25

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎cuda_pathfinder/cuda/pathfinder/_utils/diagnostic_log.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _make_logger() -> logging.Logger | None:
3030
import logging
3131

3232
name = raw.upper()
33-
level = int(raw) if raw.isdigit() else getattr(logging, name) if name in _LEVEL_NAMES else None
33+
level = int(raw) if raw.isdecimal() else getattr(logging, name) if name in _LEVEL_NAMES else None
3434
if level is None:
3535
warnings.warn(f"{ENV_VAR_NAME}={raw!r} is not a valid logging level; logging stays disabled.", stacklevel=2)
3636
return None

‎cuda_pathfinder/tests/test_diagnostic_log.py‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from cuda.pathfinder._dynamic_libs.load_dl_common import DynamicLibNotFoundError, LoadedDL
1515
from cuda.pathfinder._utils import diagnostic_log
1616

17+
pytestmark = pytest.mark.thread_unsafe(reason="reloads diagnostic_log under a patched os.environ")
18+
1719
ENV_VAR = diagnostic_log.ENV_VAR_NAME
1820
LOGGER_NAME = diagnostic_log.LOGGER_NAME
1921
LOADED = LoadedDL("/opt/cuda/lib64/libcudart.so.12", False, 1234, "CUDA_PATH")
@@ -54,10 +56,11 @@ def test_env_var_enables_logger(value, level):
5456
assert all(isinstance(h, logging.NullHandler) for h in logger.handlers)
5557

5658

59+
@pytest.mark.parametrize("value", ["VERBOSE", "\u00b2"]) # superscript two: isdigit() but not int()-parsable
5760
@pytest.mark.agent_authored(model="claude-opus-5")
58-
def test_invalid_value_warns_and_stays_disabled():
61+
def test_invalid_value_warns_and_stays_disabled(value):
5962
with pytest.warns(UserWarning, match=ENV_VAR):
60-
assert reload_with_env("VERBOSE").LOGGER is None
63+
assert reload_with_env(value).LOGGER is None
6164

6265

6366
@pytest.mark.agent_authored(model="claude-opus-5")

0 commit comments

Comments
 (0)