Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare two lists, dictionaries in easy way

Tags:

python

nose

How to compare two lists or dictionaries in easy way,

eg.

assert orig_list == new_list

If I want to check two lists in python nose tests,

Is there any built-in function can let me use?

Does compare two lists is a bad practice when doing testing ?(because I've never see it)

If there is no built-in, plugin in nose, is there any handy package can do it for me.

like image 431
newBike Avatar asked Mar 10 '14 06:03

newBike


1 Answers

You can use assertListEqual(a, b) and assertDictEqual(a, b) from the unittest library.

like image 170
psytau Avatar answered Sep 26 '22 16:09

psytau