这个测试结果让我大吃一惊。这可能是什么错?毕竟这是完全相同的词。
======================================================================
FAIL: test_make_table_list_supplier_unknown (__main__.ConvertingListToDic)
----------------------------------------------------------------------
Traceback (most recent call last):
File "test_scraping.py", line 20, in test_make_table_list_supplier_unknown
self.assertIs(no_supplier_table[0].get('ingredient list')[0]['ingredient'], 'Crystalline Silica')
AssertionError: 'Crystalline Silica' is not 'Crystalline Silica'
请您参考如下方法:
assertIs(a, b) 检查 a 和 b 是否是同一个对象。
您可能只想检查值,在这种情况下使用 assertEqual()
self.assertEqual(no_supplier_table[0].get('ingredient list')[0]['ingredient'], 'Crystalline Silica')
请注意,还有一个 assertEquals(),它已被弃用,因此请务必使用 assertEqual()
有关更多详细信息,请参阅 python 文档。
https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertIs
和
https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertEqual
