<?xml version="1.0" encoding="utf-8"?><testsuites name="pytest tests"><testsuite name="pytest" errors="0" failures="2" skipped="0" tests="3" time="0.094" timestamp="2026-08-09T09:18:37.002120+00:00" hostname="cube-B850M-AORUS-ELITE-WIFI6E-ICE"><testcase classname="tests.gateway.test_telegram_mock_bootstrap" name="test_ensure_telegram_mock_replaces_only_invalid_preloaded_package_tree[none]" time="0.031"><failure message="AssertionError: assert &lt;module 'telegram'&gt; is not &lt;module 'telegram'&gt;">monkeypatch = &lt;_pytest.monkeypatch.MonkeyPatch object at 0x7831fa0d2120&gt;
chat_type = None, expect_replacement = True

    @pytest.mark.parametrize(
        ("chat_type", "expect_replacement"),
        [
            (None, True),
            (_MISSING, True),
            (SimpleNamespace(GROUP="existing"), False),
        ],
        ids=("none", "missing", "valid_fake"),
    )
    def test_ensure_telegram_mock_replaces_only_invalid_preloaded_package_tree(
        monkeypatch, chat_type, expect_replacement
    ):
        """Missing ChatType must not let a cached package bypass the shared mock."""
        telegram, constants, error = _preloaded_telegram_tree(chat_type)
        modules = {
            "telegram": telegram,
            "telegram.constants": constants,
            "telegram.error": error,
            "telegram.ext": telegram.ext,
            "telegram.request": telegram.request,
        }
        for name, module in modules.items():
            monkeypatch.setitem(sys.modules, name, module)
    
        _ensure_telegram_mock()
    
        if expect_replacement:
&gt;           assert sys.modules["telegram"] is not telegram
E           AssertionError: assert &lt;module 'telegram'&gt; is not &lt;module 'telegram'&gt;

tests/gateway/test_telegram_mock_bootstrap.py:59: AssertionError</failure></testcase><testcase classname="tests.gateway.test_telegram_mock_bootstrap" name="test_ensure_telegram_mock_replaces_only_invalid_preloaded_package_tree[missing]" time="0.003"><failure message="AssertionError: assert &lt;module 'telegram'&gt; is not &lt;module 'telegram'&gt;">monkeypatch = &lt;_pytest.monkeypatch.MonkeyPatch object at 0x7831fa0e00b0&gt;
chat_type = &lt;object object at 0x7831fd22ab90&gt;, expect_replacement = True

    @pytest.mark.parametrize(
        ("chat_type", "expect_replacement"),
        [
            (None, True),
            (_MISSING, True),
            (SimpleNamespace(GROUP="existing"), False),
        ],
        ids=("none", "missing", "valid_fake"),
    )
    def test_ensure_telegram_mock_replaces_only_invalid_preloaded_package_tree(
        monkeypatch, chat_type, expect_replacement
    ):
        """Missing ChatType must not let a cached package bypass the shared mock."""
        telegram, constants, error = _preloaded_telegram_tree(chat_type)
        modules = {
            "telegram": telegram,
            "telegram.constants": constants,
            "telegram.error": error,
            "telegram.ext": telegram.ext,
            "telegram.request": telegram.request,
        }
        for name, module in modules.items():
            monkeypatch.setitem(sys.modules, name, module)
    
        _ensure_telegram_mock()
    
        if expect_replacement:
&gt;           assert sys.modules["telegram"] is not telegram
E           AssertionError: assert &lt;module 'telegram'&gt; is not &lt;module 'telegram'&gt;

tests/gateway/test_telegram_mock_bootstrap.py:59: AssertionError</failure></testcase><testcase classname="tests.gateway.test_telegram_mock_bootstrap" name="test_ensure_telegram_mock_replaces_only_invalid_preloaded_package_tree[valid_fake]" time="0.003" /></testsuite></testsuites>