当我运行PyTest时,我得到一些测试失败
....
!!! Recursion detected (same locals & position)
然而,当我手动运行测试时,我发现没有无限递归。我的代码做了一些奇怪的事情,可能会欺骗pytest的递归检测器。
有没有办法禁用某些测试的递归检查?
我正在运行PyTest 3.0.1
答案 0 :(得分:0)
如果要在递归代码引用的模拟函数上设置def parse(self, response):
for search_result in response.css(".room-tile.rowSearchResultRoom"):
postal_code = search_result.css("meta[itemprop=postalCode]::attr(content)").extract_first()
href = search_result.xpath("@href").extract_first()
yield scrapy.Request(response.urljoin(href),
meta={'postal_code': postal_code},
callback=self.parse_ad)
def parse_ad(self, response):
postal_code = response.meta['postal_code']
# get char1 and char2..
yield {'char1': char1,
'char2': char2,
'postal_code': postal_code}
,请改用return_value
。