Skip to content

Commit

Permalink
fixing broken test after converting to using future annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
bandophahita committed Jan 15, 2024
1 parent 8f828af commit b8335dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
3 changes: 1 addition & 2 deletions tests/test_questions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from typing import Optional
from unittest import mock

import pytest
Expand Down Expand Up @@ -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")
Expand Down
36 changes: 28 additions & 8 deletions tests/test_resolutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

0 comments on commit b8335dd

Please sign in to comment.