Skip to content

Commit

Permalink
xfail tests for web_poet.field typing (#88)
Browse files Browse the repository at this point in the history
kmike authored Oct 17, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7341c36 commit 551aa3b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests_typing/test_fields.mypy-testing
Original file line number Diff line number Diff line change
@@ -15,11 +15,50 @@ class Page(ItemPage):
return "hello"


def process_price(value: float) -> float:
return max([0, value])


class TypedPage(ItemPage):
@field
def description(self) -> str:
return "hello"

@field(out=[str.strip])
def name(self) -> str:
return "hello"

@field(out=[process_price, str])
def price(self) -> float:
return 123.0


@attrs.define
class Item:
name: str


@pytest.mark.mypy_testing
@pytest.mark.xfail
async def test_field_type() -> None:
page = TypedPage()
reveal_type(page.description) # R: builtins.str


@pytest.mark.mypy_testing
@pytest.mark.xfail
async def test_field_type_out() -> None:
page = TypedPage()
reveal_type(page.name) # R: builtins.str


@pytest.mark.mypy_testing
@pytest.mark.xfail
async def test_field_type_changed_type() -> None:
page = TypedPage()
reveal_type(page.price) # R: builtins.str


@pytest.mark.mypy_testing
async def test_item_from_fields() -> None:
page = Page()

0 comments on commit 551aa3b

Please sign in to comment.