Python assertion error during nosetest?

711 views Asked by At

While testing i am getting assertion error like below

AssertionError: Actual Items Not In Expected: [{'handicapped': False, 'first_name': u'JAMES', 'substance_abuse': False, 'tobacco_use': False}]

here expected values are equal to actual . If both are same why it still expect ?

1

There are 1 answers

2
wim On BEST ANSWER

The "actual" data has more keys in it, which your test was apparently not written to expect. So the dicts are not equal, even if expected is a valid subdict of actual.

If you want only the keys present in expected to be present in the output, then you have a valid test failure here.

However, if you don't mind having "extra" keys in the actual output, then you should write a better assertion, for example using unittest.TestCase.assertDictContainsSubset.