Debian Codegraph @

test/units/_internal/_patches/test_patch.py

raw
1 from __future__ import annotations
2
3 import pytest
4 import typing as t
5
6 from ansible.module_utils._internal._patches import CallablePatch
7
8
9 class BogusPatch(CallablePatch):
10 """Coverage-oriented simulated patch where the patch is required but the original implementation to be patched does not exist."""
11
12 target_container: t.ClassVar = dict
13 target_attribute = '_bogus_dict_attr'
14
15 @classmethod
16 def is_patch_needed(cls) -> bool:
17 return True
18
19 def __call__(self, annotation, cls, a_module, a_type, is_type_predicate) -> bool:
20 raise NotImplementedError("should not be called") # pragma: nocover
21
22
23 def test_bogus_patch():
24 with pytest.raises(RuntimeError, match="implementation to be patched .* is not present"):
25 BogusPatch.patch()