Hi,
I am new to Python and and am trying to learn testing (using unittest).
How do I assert that a dictionary contains a key?
Cheers,
Mick
You want to assert or just test if the key in dict?
assert some_key in some_dict
, which is same as
assert some_key in some_dict.keys()
?
or in unnittets
assertIn(some_key, some_dict)
assertIn(some_key, some_dict.keys())
https://docs.python.org/3/library/unitte...e.assertIn
Brilliant, thanks. I suspected it should be that simple.:-)
just to add -
pytest is really nice test suite