fix: resolve test_username.py import for plugins/ directory

Load plugins.username via importlib.util.spec_from_file_location
since plugins/ is not a Python package on sys.path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-15 06:17:11 +01:00
parent 5dd4460d59
commit 7184c43b08

View File

@@ -1,6 +1,18 @@
"""Tests for the username enumeration plugin."""
from plugins.username import (
import importlib.util
import sys
from pathlib import Path
# plugins/ is not a Python package -- load the module from file path
_spec = importlib.util.spec_from_file_location(
"plugins.username", Path(__file__).resolve().parent.parent / "plugins" / "username.py",
)
_mod = importlib.util.module_from_spec(_spec)
sys.modules[_spec.name] = _mod
_spec.loader.exec_module(_mod)
from plugins.username import ( # noqa: E402
_BY_CATEGORY,
_BY_NAME,
_SERVICES,