Skip to content

The agent that grows with you

test: gate the Discord role probe on the real distribution, not the conftest mock

Teknium19feada07755
diff --git a/tests/gateway/test_native_role_reauthorization.py b/tests/gateway/test_native_role_reauthorization.py
index 796c99490d3..b69ba263af5 100644
--- a/tests/gateway/test_native_role_reauthorization.py
+++ b/tests/gateway/test_native_role_reauthorization.py
@@ -4,10 +4,15 @@ from pathlib import Path
import subprocess
import sys
+import importlib.machinery
+
import pytest
-# The probe drives the real Discord adapter (a `messaging` extra); CI's base venv has no discord.py.
-pytest.importorskip("discord")
+# The probe is a fresh interpreter driving the real Discord adapter; tests/gateway/conftest.py's
+# in-process MagicMock ``discord`` shadows sys.modules here, so ask the path finder for the REAL
+# distribution (a `messaging` extra absent from the CI venv) instead of the import cache.
+if importlib.machinery.PathFinder.find_spec("discord") is None:
+ pytest.skip("discord.py not installed (messaging extra)", allow_module_level=True)
def _probe(tmp_path, mode):