def test_set_context(parser): other_name = 'different_from_any_name' p = Parser(INPUT_DICT, ANY_NAME) p.mark_object = mock.Mock() p.set_context(other_name, ANY_OBJ) assert p.name == other_name assert p.obj is ANY_OBJ assert p.mark_object.called_once_with(ANY_OBJ)