如何对包含列表的元组进行单元测试(断言)?

How to unittest (assert) tuple containing list?

我有一个元组:

expected = (list, string)

第一个参数是一个列表,第二个是字符串。

列表项可以有任何顺序。通常在断言列表时我会做 assertCountEqual() 来检查项目而不考虑顺序。如何对包含列表的元组进行单元测试?

def assertMyTupleEqual(self, expected, actual):
    self.assertEqual(type(expected), type(actual))  # check they are the same type
    self.assertEqual(len(expected), len(actual))  # check they are the same length
    self.assertEqual(expected[1], actual[1])  # check they have the same string
    self.assertCountEqual(expected[0], actual[0])  # check they have the same list