MCPcopy
hub / github.com/scrapy/scrapy / test_custom_methods

Method test_custom_methods

tests/test_item.py:91–107  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

89 i.name = "john"
90
91 def test_custom_methods(self):
92 class TestItem(Item):
93 name = Field()
94
95 def get_name(self):
96 return self["name"]
97
98 def change_name(self, name):
99 self["name"] = name
100
101 i = TestItem()
102 with pytest.raises(KeyError):
103 i.get_name()
104 i["name"] = "lala"
105 assert i.get_name() == "lala"
106 i.change_name("other")
107 assert i.get_name() == "other"
108
109 def test_metaclass(self):
110 class TestItem(Item):

Callers

nothing calls this directly

Calls 3

get_nameMethod · 0.95
change_nameMethod · 0.95
TestItemClass · 0.70

Tested by

no test coverage detected