Python unittest - asserting dictionary with lists

后端 未结 4 846
挽巷
挽巷 2021-02-19 08:22

While writing some tests for my class, I encountered interesting simple problem. I would like to assertDictEqual two dictionaries containing some list. But this lists may not be

4条回答
  •  日久生厌
    2021-02-19 08:28

    maybe you can check for the two elements separately:

        obj_dict = obj.exportToDict()
        self.assertEqual(resulting_dictionary['state'], obj_dict['state'])
        self.assertCountEqual(resulting_dictionary['neighbours'], obj_dict['neighbours'])
    

提交回复
热议问题