self = <tests.petclinic.test_owner.test_onwer_search.TestOwnerSearch object at 0x0000020ED2C4C5B0> keyword = 'balck' @pytest.mark.parametrize('keyword',[ 'balck', 'avis' ]) def test_search_none(self,keyword): # 搜索 # owner_list = self.owner_page.search(keyword) msg = self.owner_page.search_none(keyword) > assert 'No owners' in msg E TypeError: argument of type 'NoneType' is not iterable test_onwer_search.py:44: TypeError
时间: 2024-03-21 11:43:33 浏览: 102
sdk_memory_test.zip_memory_sdk memory tests_sdk里memory test_xili
这个错误是因为`msg`为`None`,而在`assert`语句中尝试迭代`None`类型的值,导致了`TypeError`异常。这个问题可能是由于`self.owner_page.search_none(keyword)`返回了`None`,而不是预期的字符串类型。
可以在`self.owner_page.search_none(keyword)`方法中打印一些调试信息,以便查看返回的值是否为`None`。例如:
```python
def search_none(self, keyword):
self.search(keyword)
try:
WebDriverWait(self.driver, 5).until(EC.presence_of_element_located((By.XPATH, "//tbody")))
except TimeoutException:
return "No owners"
else:
return None
```
然后,您可以在测试函数中打印`msg`的值,查看它是否为`None`。如果是,则需要在`search_none`方法中进行调整,以确保它返回预期的字符串类型。
阅读全文