diff --git a/tests/test_autowire.py b/tests/test_autowire.py index cc9a783..da86560 100644 --- a/tests/test_autowire.py +++ b/tests/test_autowire.py @@ -420,3 +420,63 @@ class TestMarkAutowiredEdgeCases: # Конструктор вложенного класса зарегистрирован assert len(repo.convertor_set) == 1 + + def test_is_basic_type_with_none(self): + """_is_basic_type с None.""" + from breakshaft.autowire import _is_basic_type + + assert _is_basic_type(None) is True + + def test_is_basic_type_with_basic_types(self): + """_is_basic_type с базовыми типами.""" + from breakshaft.autowire import _is_basic_type + + assert _is_basic_type(int) is True + assert _is_basic_type(str) is True + assert _is_basic_type(float) is True + assert _is_basic_type(bool) is True + + def test_get_constructor_signature_error(self): + """_get_constructor_signature с ошибкой.""" + from breakshaft.autowire import _get_constructor_signature + + class BadInit: + __init__ = None # type: ignore + + result = _get_constructor_signature(BadInit) + assert result is None + + def test_get_method_signature_error(self): + """_get_method_signature с ошибкой.""" + from breakshaft.autowire import _get_method_signature + + def bad_method(): + pass + + # Удаляем аннотации чтобы вызвать ошибку + bad_method.__annotations__ = None # type: ignore + + result = _get_method_signature(bad_method) + assert result is None + + def test_should_register_false(self): + """_should_register возвращает False для дубликата.""" + from breakshaft.autowire import _should_register + + repo = ConvRepo() + + @repo.mark_injector() + def a_to_b(a: A) -> B: + return B(float(a.a)) + + # Должен вернуть False (уже есть такой инжектор) + result = _should_register(repo, (A,), B) + assert result is False + + def test_mark_autowired_without_repo(self): + """mark_autowired без repo.""" + from breakshaft.autowire import mark_autowired + + # Вызов без repo возвращает decorator + decorator = mark_autowired(None) # type: ignore + assert callable(decorator)