mocker = <pytest_mock.plugin.MockerFixture object at 0x7f346df79668>
class_ = 'memory'
expected_class = <class 'swh.search.in_memory.InMemorySearch'>, kwargs = None
@pytest.mark.parametrize("class_,expected_class,kwargs", SEARCH_IMPLEMENTATIONS)
def test_types(mocker, class_, expected_class, kwargs):
"""Checks all methods of SearchInterface are implemented by this
backend, and that they have the same signature.
"""
mocker.patch("swh.search.elasticsearch.Elasticsearch")
if kwargs:
concrete_search = get_search(class_, **kwargs)
else:
concrete_search = get_search(class_)
# Create an instance of the protocol (which cannot be instantiated
# directly, so this creates a subclass, then instantiates it)
interface = type("_", (SearchInterface,), {})()
for meth_name in dir(interface):
if meth_name.startswith("_"):
continue
interface_meth = getattr(interface, meth_name)
missing_methods = []
try:
concrete_meth = getattr(concrete_search, meth_name)
except AttributeError:
if not getattr(interface_meth, "deprecated_endpoint", False):
# The backend is missing a (non-deprecated) endpoint
missing_methods.append(meth_name)
continue
expected_signature = inspect.signature(interface_meth)
actual_signature = inspect.signature(concrete_meth)
> assert expected_signature == actual_signature, meth_name
E AssertionError: origin_get
E assert <Signature (url: List[str]) -> Union[Dict[str, str], NoneType]> == <Signature (url: str) -> Union[Dict[str, str], NoneType]>
.tox/py3/lib/python3.7/site-packages/swh/search/tests/test_init.py:86: AssertionError
TEST RESULT
TEST RESULT
- Run At
- Oct 7 2022, 11:12 AM