diff --git a/swh/model/tests/test_hypothesis_strategies.py b/swh/model/tests/test_hypothesis_strategies.py --- a/swh/model/tests/test_hypothesis_strategies.py +++ b/swh/model/tests/test_hypothesis_strategies.py @@ -20,10 +20,26 @@ attr.validate(object_) +def assert_nested_dict(obj): + """Tests the object is a nested dict and contains no more class + from swh.model.model.""" + if isinstance(obj, dict): + for (key, value) in obj.items(): + assert isinstance(key, (str, bytes)), key + assert_nested_dict(value) + elif isinstance(obj, list): + for value in obj: + assert_nested_dict(value) + elif isinstance(obj, (int, float, str, bytes, bool, type(None))): + pass + else: + assert False, obj + + @given(object_dicts()) def test_dicts_generation(obj_type_and_obj): (obj_type, object_) = obj_type_and_obj - assert isinstance(object_, dict) + assert_nested_dict(object_) if obj_type == 'content': if object_['status'] == 'visible': assert set(object_) == \