1

This test result boggles my mind. What could be the fault of this? It is the exact same word after all.

======================================================================
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'

2 Answers 2

6

assertIs(a, b) checks if a and b are the same object.

You probably want to check for value only, in that case use assertEqual()

self.assertEqual(no_supplier_table[0].get('ingredient list')[0]['ingredient'], 'Crystalline Silica')

Note that there is also an assertEquals(), which is deprecated so be sure to use assertEqual()

See the python docs for more detailed information.

https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertIs

and

https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertEqual

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I was reading the docs, but I should have read it more carefully. Also it's kind of curious that no_supplier_table[0].get('ingredient list')[0].get('ingredient') works fine with assertIs.
2

is tests object identity. Distinct objects can be equal; what you want is assertEqual.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.