diff --git a/platformio/datamodel.py b/platformio/datamodel.py index 53b99c29..600de738 100644 --- a/platformio/datamodel.py +++ b/platformio/datamodel.py @@ -209,7 +209,12 @@ class DataModel(object): raise DataFieldException( field, "Value `%s` should be type of dictionary" % v ) - result.append(data_type(**v)) + m = data_type(**v) + me = m.get_exceptions() + if not me: + result.append(m) + else: + self._exceptions |= set(me) except DataFieldException as e: self._exceptions.add(e) if isinstance(self, StrictDataModel): @@ -235,7 +240,12 @@ class DataModel(object): raise DataFieldException( field, "Value `%s` should be type of dictionary" % v ) - result[k] = data_type(**v) + m = data_type(**v) + me = m.get_exceptions() + if not me: + result[k] = m + else: + self._exceptions |= set(me) except DataFieldException as e: self._exceptions.add(e) if isinstance(self, StrictDataModel): @@ -246,8 +256,6 @@ class DataModel(object): assert isinstance(other, DataModel) if self.get_field_names() != other.get_field_names(): return False - if len(self.get_exceptions()) != len(other.get_exceptions()): - return False return self.as_dict() == other.as_dict() def __repr__(self): diff --git a/tests/test_pkgmanifest.py b/tests/test_pkgmanifest.py index 3bca641b..cb3fc38c 100644 --- a/tests/test_pkgmanifest.py +++ b/tests/test_pkgmanifest.py @@ -265,7 +265,7 @@ def test_library_json_model(): ) -def library_properties_model(): +def test_library_properties_model(): contents = """ name=U8glib version=1.19.1 @@ -315,6 +315,58 @@ architectures=avr,sam } ) + # Broken fields + contents = """ +name=Mozzi +version=1.0.3 +author=Tim Barrass and contributors as documented in source, and at https://github.com/sensorium/Mozzi/graphs/contributors +maintainer=Tim Barrass +sentence=Sound synthesis library for Arduino +paragraph=With Mozzi, you can construct sounds using familiar synthesis units like oscillators, delays, filters and envelopes. +category=Signal Input/Output +url=https://sensorium.github.io/Mozzi/ +architectures=* +dot_a_linkage=false +includes=MozziGuts.h +""" + data = parser.ManifestParserFactory.new( + contents, + parser.ManifestFileType.LIBRARY_PROPERTIES, + remote_url=( + "https://raw.githubusercontent.com/sensorium/Mozzi/" + "master/library.properties" + ), + ).as_dict() + m = model.ManifestModel(**data) + assert m.get_exceptions() + assert m == model.ManifestModel( + **{ + "name": "Mozzi", + "version": "1.0.3", + "description": ( + "Sound synthesis library for Arduino. With Mozzi, you can construct " + "sounds using familiar synthesis units like oscillators, delays, " + "filters and envelopes." + ), + "repository": {"url": "https://github.com/sensorium/Mozzi", "type": "git"}, + "platforms": ["*"], + "frameworks": ["arduino"], + "export": { + "exclude": ["extras", "docs", "tests", "test", "*.doxyfile", "*.pdf"], + "include": None, + }, + "authors": [ + { + "maintainer": True, + "email": "faveflave@gmail.com", + "name": "Tim Barrass", + } + ], + "keywords": ["signal", "input", "output"], + "homepage": "https://sensorium.github.io/Mozzi/", + } + ) + def test_platform_json_model(): contents = """