diff --git a/manifest_xml.py b/manifest_xml.py index 30e96584..09cae6f5 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -122,9 +122,13 @@ class _Default(object): sync_tags = True def __eq__(self, other): + if not isinstance(other, _Default): + return False return self.__dict__ == other.__dict__ def __ne__(self, other): + if not isinstance(other, _Default): + return True return self.__dict__ != other.__dict__ @@ -147,12 +151,18 @@ class _XmlRemote(object): self.resolvedFetchUrl = self._resolveFetchUrl() def __eq__(self, other): + if not isinstance(other, _XmlRemote): + return False return self.__dict__ == other.__dict__ def __ne__(self, other): + if not isinstance(other, _XmlRemote): + return True return self.__dict__ != other.__dict__ def _resolveFetchUrl(self): + if self.fetchUrl is None: + return '' url = self.fetchUrl.rstrip('/') manifestUrl = self.manifestUrl.rstrip('/') # urljoin will gets confused over quite a few things. The ones we care diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index bd74780d..2a16900a 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -607,3 +607,34 @@ class ContactinfoElementTests(ManifestParseTestCase): '' f'' '') + + +class DefaultElementTests(ManifestParseTestCase): + """Tests for .""" + + def test_default(self): + """Check default settings.""" + a = manifest_xml._Default() + a.revisionExpr = 'foo' + a.remote = manifest_xml._XmlRemote(name='remote') + b = manifest_xml._Default() + b.revisionExpr = 'bar' + self.assertEqual(a, a) + self.assertNotEqual(a, b) + self.assertNotEqual(b, a.remote) + self.assertNotEqual(a, 123) + self.assertNotEqual(a, None) + + +class RemoteElementTests(ManifestParseTestCase): + """Tests for .""" + + def test_remote(self): + """Check remote settings.""" + a = manifest_xml._XmlRemote(name='foo') + b = manifest_xml._XmlRemote(name='bar') + self.assertEqual(a, a) + self.assertNotEqual(a, b) + self.assertNotEqual(a, manifest_xml._Default()) + self.assertNotEqual(a, 123) + self.assertNotEqual(a, None)