mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
Merge pull request #1314 from NousResearch/fix/discord-import-safety
fix: defer discord adapter annotations
This commit is contained in:
commit
c6cc92295c
2 changed files with 25 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
|
||||
"""
|
||||
Discord platform adapter.
|
||||
|
||||
|
|
|
|||
23
tests/gateway/test_discord_imports.py
Normal file
23
tests/gateway/test_discord_imports.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
"""Import-safety tests for the Discord gateway adapter."""
|
||||
|
||||
import builtins
|
||||
import importlib
|
||||
import sys
|
||||
|
||||
|
||||
class TestDiscordImportSafety:
|
||||
def test_module_imports_even_when_discord_dependency_is_missing(self, monkeypatch):
|
||||
original_import = builtins.__import__
|
||||
|
||||
def fake_import(name, globals=None, locals=None, fromlist=(), level=0):
|
||||
if name == "discord" or name.startswith("discord."):
|
||||
raise ImportError("discord unavailable for test")
|
||||
return original_import(name, globals, locals, fromlist, level)
|
||||
|
||||
monkeypatch.delitem(sys.modules, "gateway.platforms.discord", raising=False)
|
||||
monkeypatch.setattr(builtins, "__import__", fake_import)
|
||||
|
||||
module = importlib.import_module("gateway.platforms.discord")
|
||||
|
||||
assert module.DISCORD_AVAILABLE is False
|
||||
assert module.discord is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue