我有一个 Python 3.8 单元测试,它曾经可以正常工作,但现在它失败了。我看不到任何说明该方法已被弃用的文档,所以我想知道这里发生了什么。
单元测试这样做:
- 确保我们实例化了 Bottlenose 客户端
- 去查找一些产品
def test_amazon_client(self):
"""
Test that amazon client is created.
"""
self.assertIsNotNone(self.amazon)
def test_asin(self):
"""
Test that amazon client is pulling product data.
"""
result = self.amazon.ItemLookup(ItemId="B000Q5Z8L0")
self.assertIsNotNone(result)
当单元测试运行时,输出显示“HTTP 410: Gone”错误。
======================================================================
ERROR: test_asin (__main__.TestAmazon)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/jasoncoulls/Desktop/WORK/[redacted]/scrap.py", line 28, in test_asin
result = self.amazon.ItemLookup(ItemId="B000Q5Z8L0")
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bottlenose/api.py", line 273, in __call__
response = self._call_api(api_url,
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/bottlenose/api.py", line 235, in _call_api
return urllib2.urlopen(api_request, timeout=self.Timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 531, in open
response = meth(req, response)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 640, in http_response
response = self.parent.error(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain
result = func(*args)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 410: Gone
所以这让我摸不着头脑。
- 我确保我使用的是最新的 boto3 客户端。
- 我确保正在查找的项目是有效的。
- 我确保正在实例化客户端。
任何其他指针都会有所帮助。