Skip to content

Commit

Permalink
add test case for subclass overriding field from parent class using t…
Browse files Browse the repository at this point in the history
…o_item()
  • Loading branch information
BurnzZ committed Sep 28, 2022
1 parent dd4dec9 commit 1479cf6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ def field3(self):
assert get_fields_dict(Page2)["field3"].meta == {"foo": "bar"}
assert list(get_fields_dict(Page2)) == ["field1", "field3", "field2"]

class PageToItem(ItemPage):
def to_item(self):
return {"field1": 1, "field2": 2, "field3": 3, "field4": 4}

class Page4(PageToItem):
@field
def field4(self):
return 0

page_4 = Page4()
assert page_4.field4 == 0
assert page_4.to_item() == {"field1": 1, "field2": 2, "field3": 3, "field4": 0}


def test_field_with_other_decorators() -> None:
def clean_str(method):
Expand Down

0 comments on commit 1479cf6

Please sign in to comment.