diff --git a/tests/test_questions.py b/tests/test_questions.py index 4b5fac0..d7474f0 100644 --- a/tests/test_questions.py +++ b/tests/test_questions.py @@ -1,6 +1,5 @@ from __future__ import annotations -from typing import Optional from unittest import mock import pytest @@ -171,7 +170,7 @@ def test_caught_exception_annotation(self) -> None: e = Element(TARGET) annotation = e.__annotations__["caught_exception"] - assert annotation == Optional[TargetingError] + assert annotation == "Optional[TargetingError]" def test_question_returns_none_if_no_element_found(self, Tester: Actor) -> None: test_target = Target.the("foo").located_by("//bar") diff --git a/tests/test_resolutions.py b/tests/test_resolutions.py index a7ff11a..23cf502 100644 --- a/tests/test_resolutions.py +++ b/tests/test_resolutions.py @@ -8,6 +8,18 @@ from selenium.webdriver.remote.webelement import WebElement from screenpy_selenium import IsClickable, IsInvisible, IsPresent, IsVisible +from screenpy_selenium.resolutions.custom_matchers.is_clickable_element import ( + IsClickableElement, +) +from screenpy_selenium.resolutions.custom_matchers.is_invisible_element import ( + IsInvisibleElement, +) +from screenpy_selenium.resolutions.custom_matchers.is_present_element import ( + IsPresentElement, +) +from screenpy_selenium.resolutions.custom_matchers.is_visible_element import ( + IsVisibleElement, +) from .useful_mocks import get_mocked_element @@ -39,10 +51,6 @@ def _assert_descriptions( assert describe_none.out == expected.describe_none -def assert_matcher_annotation(obj: BaseResolution) -> None: - assert type(obj.matcher) is obj.__annotations__["matcher"] - - class TestIsClickable: def test_can_be_instantiated(self) -> None: ic = IsClickable() @@ -83,7 +91,10 @@ def test_descriptions(self) -> None: _assert_descriptions(IsClickable(), element, expected) def test_type_hint(self) -> None: - assert_matcher_annotation(IsClickable()) + ic = IsClickable() + annotation = ic.__annotations__["matcher"] + assert annotation == "IsClickableElement" + assert type(ic.matcher) == IsClickableElement class TestIsVisible: @@ -119,7 +130,10 @@ def test_descriptions(self) -> None: _assert_descriptions(IsVisible(), element, expected) def test_type_hint(self) -> None: - assert_matcher_annotation(IsVisible()) + iv = IsVisible() + annotation = iv.__annotations__["matcher"] + assert annotation == "IsVisibleElement" + assert type(iv.matcher) == IsVisibleElement class TestIsInvisible: @@ -169,7 +183,10 @@ def test_descriptions(self) -> None: assert describe_none.out == expected.describe_none def test_type_hint(self) -> None: - assert_matcher_annotation(IsInvisible()) + ii = IsInvisible() + annotation = ii.__annotations__["matcher"] + assert annotation == "IsInvisibleElement" + assert type(ii.matcher) == IsInvisibleElement class TestIsPresent: @@ -207,4 +224,7 @@ def test_descriptions(self) -> None: _assert_descriptions(IsPresent(), element, expected) def test_type_hint(self) -> None: - assert_matcher_annotation(IsPresent()) + ip = IsPresent() + annotation = ip.__annotations__["matcher"] + assert annotation == "IsPresentElement" + assert type(ip.matcher) == IsPresentElement