[AUTO-INF-2] Fix nox configuration for unit_tests session #8313

Closed
opened 2026-04-13 08:26:35 +00:00 by HAL9000 · 1 comment
Owner

Summary

  • The unit_tests nox session hard-codes the behave-parallel binary path, which crashes on Windows runners because the executable requires a .exe suffix.
  • The session overwrites PYTHONPATH, dropping any caller-supplied entries (coverage instrumentation, plugin paths), which triggers ModuleNotFoundError failures when upstream tooling sets that variable.
  • Adjust the session to rely on nox's command resolution and to preserve any existing PYTHONPATH entries while keeping the rest of the workflow intact.

Analysis

  • Our Windows-based smoke run failed with CreateProcess failed; code 2: The system cannot find the file specified when trying to execute /.../.nox/unit_tests-3-13/bin/behave-parallel because the .exe wrapper is the real entry point on Windows.
  • On CI, tooling that injects telemetry collectors via PYTHONPATH currently loses those shims because unit_tests sets it to str(Path("src").resolve()) with no concatenation; subsequent imports (e.g., coverage adapters) fail.
  • Both problems stem from the session tying itself too closely to platform-specific paths and clobbering environment state instead of augmenting it.

Proposed Changes

@@
-    behave_cmd = session.bin + "/behave-parallel"
-    parallel_args = _behave_parallel_args(session.posargs)
+    parallel_args = _behave_parallel_args(session.posargs)
@@
-        args = [
-            behave_cmd,
-            "-q",
-            "--tags=not @skip",
-            *parallel_args,
-            *session.posargs,
-        ]
+        behave_args = [
+            "behave-parallel",
+            "-q",
+            "--tags=not @skip",
+            *parallel_args,
+            *session.posargs,
+        ]
     else:
-        args = [
-            behave_cmd,
-            "-q",
-            "--tags=not @skip",
-            *parallel_args,
-            "features/",
-            *session.posargs,
-        ]
+        behave_args = [
+            "behave-parallel",
+            "-q",
+            "--tags=not @skip",
+            *parallel_args,
+            "features/",
+            *session.posargs,
+        ]
 
-    session.env["PYTHONPATH"] = str(Path("src").resolve())
+    session.env["PYTHONPATH"] = os.pathsep.join(
+        filter(
+            None,
+            (
+                str(Path("src").resolve()),
+                session.env.get("PYTHONPATH"),
+            ),
+        )
+    )
@@
-    session.run(*args)
+    session.run(*behave_args)

Duplicate Check

  • 2026-04-13: Searched open issues for nox, unit_tests, and behave-parallel — no existing tickets cover this configuration bug.

Automated by CleverAgents Bot
Supervisor: Test Infrastructure Pool | Agent: test-infra-worker

## Summary - The `unit_tests` nox session hard-codes the `behave-parallel` binary path, which crashes on Windows runners because the executable requires a `.exe` suffix. - The session overwrites `PYTHONPATH`, dropping any caller-supplied entries (coverage instrumentation, plugin paths), which triggers `ModuleNotFoundError` failures when upstream tooling sets that variable. - Adjust the session to rely on nox's command resolution and to preserve any existing `PYTHONPATH` entries while keeping the rest of the workflow intact. ## Analysis - Our Windows-based smoke run failed with `CreateProcess failed; code 2: The system cannot find the file specified` when trying to execute `/.../.nox/unit_tests-3-13/bin/behave-parallel` because the `.exe` wrapper is the real entry point on Windows. - On CI, tooling that injects telemetry collectors via `PYTHONPATH` currently loses those shims because `unit_tests` sets it to `str(Path("src").resolve())` with no concatenation; subsequent imports (e.g., coverage adapters) fail. - Both problems stem from the session tying itself too closely to platform-specific paths and clobbering environment state instead of augmenting it. ## Proposed Changes ```diff @@ - behave_cmd = session.bin + "/behave-parallel" - parallel_args = _behave_parallel_args(session.posargs) + parallel_args = _behave_parallel_args(session.posargs) @@ - args = [ - behave_cmd, - "-q", - "--tags=not @skip", - *parallel_args, - *session.posargs, - ] + behave_args = [ + "behave-parallel", + "-q", + "--tags=not @skip", + *parallel_args, + *session.posargs, + ] else: - args = [ - behave_cmd, - "-q", - "--tags=not @skip", - *parallel_args, - "features/", - *session.posargs, - ] + behave_args = [ + "behave-parallel", + "-q", + "--tags=not @skip", + *parallel_args, + "features/", + *session.posargs, + ] - session.env["PYTHONPATH"] = str(Path("src").resolve()) + session.env["PYTHONPATH"] = os.pathsep.join( + filter( + None, + ( + str(Path("src").resolve()), + session.env.get("PYTHONPATH"), + ), + ) + ) @@ - session.run(*args) + session.run(*behave_args) ``` ### Duplicate Check - 2026-04-13: Searched open issues for `nox`, `unit_tests`, and `behave-parallel` — no existing tickets cover this configuration bug. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure Pool | Agent: test-infra-worker
Owner

superseded by next cycle

superseded by next cycle
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#8313
No description provided.