repoman.herdbase: tolerate expat ImportError
authorZac Medico <zmedico@gentoo.org>
Tue, 8 Feb 2011 10:01:13 +0000 (02:01 -0800)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 Feb 2011 10:01:13 +0000 (02:01 -0800)
We tolerate global scope import failures for optional modules, so that
ImportModulesTestCase can succeed (or possibly alert us about
unexpected import failures).

pym/portage/tests/lint/test_import_modules.py
pym/repoman/herdbase.py

index 81ffedec40872f81bc70cb925594bc608deb50a3..8d257c5a6af179d36fc878791936aef426e199d0 100644 (file)
@@ -11,7 +11,6 @@ class ImportModulesTestCase(TestCase):
 
        def testImportModules(self):
                expected_failures = frozenset((
-                       'repoman.herdbase', # requires python with xml support
                ))
 
                for mod in self._iter_modules(PORTAGE_PYM_PATH):
index 4808d3ca30292df86ae87d26a5bf9b7a52a09513..64b59e636ee1fd327158d80836c82a3b49824b40 100644 (file)
@@ -1,11 +1,18 @@
 # -*- coding: utf-8 -*-
 # repoman: Herd database analysis
-# Copyright 2010 Gentoo Foundation
+# Copyright 2010-2011 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2 or later
 
 import errno
 import xml.etree.ElementTree
-from xml.parsers.expat import ExpatError
+try:
+       from xml.parsers.expat import ExpatError
+except ImportError:
+       # This means that python is built without xml support.
+       # We tolerate global scope import failures for optional
+       # modules, so that ImportModulesTestCase can succeed (or
+       # possibly alert us about unexpected import failures).
+       pass
 from portage.exception import FileNotFound, ParseError, PermissionDenied
 
 __all__ = [