diff options
author | Andoni Morales Alastruey <ylatuya@gmail.com> | 2012-03-22 01:02:01 +0100 |
---|---|---|
committer | Andoni Morales Alastruey <ylatuya@gmail.com> | 2012-03-30 11:41:46 +0200 |
commit | 5df5e361d47e18c25ef48ae9fccbe2971dd3b441 (patch) | |
tree | 84420e65fd271694c1c7d2d5b02d16a5e4c3db20 | |
parent | c8de82f023c7f38bad7daa2bc856df9fba47c4ea (diff) |
Unify import of etree
-rw-r--r-- | cerbero/packages/wix.py | 6 | ||||
-rw-r--r-- | cerbero/tests/test_cerbero_packages_wix.py | 16 | ||||
-rw-r--r-- | cerbero/utils/__init__.py | 4 |
3 files changed, 12 insertions, 14 deletions
diff --git a/cerbero/packages/wix.py b/cerbero/packages/wix.py index cfd0678f..81596530 100644 --- a/cerbero/packages/wix.py +++ b/cerbero/packages/wix.py @@ -18,14 +18,10 @@ import os import uuid -try: - from lxml import etree -except ImportError: - import xml.etree.cElementTree as etree from cerbero.packages.package import Package from cerbero.packages.packagesstore import PackagesStore -from cerbero.utils import shell +from cerbero.utils import shell, etree from cerbero.errors import PackageNotFoundError from cerbero.config import Platform diff --git a/cerbero/tests/test_cerbero_packages_wix.py b/cerbero/tests/test_cerbero_packages_wix.py index b701710a..0deab9c5 100644 --- a/cerbero/tests/test_cerbero_packages_wix.py +++ b/cerbero/tests/test_cerbero_packages_wix.py @@ -17,14 +17,11 @@ # Boston, MA 02111-1307, USA. import unittest -try: - from lxml import etree -except ImportError: - import xml.etree.cElementTree as etree from cerbero.config import Platform from cerbero.packages import package from cerbero.packages.wix import MergeModule +from cerbero.utils import etree class DummyConfig(object): @@ -89,7 +86,8 @@ class MergeModuleTest(unittest.TestCase): def test_add_root(self): mergemodule = MergeModule(self.config, self.package) mergemodule._add_root() - self.assertEquals('<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"/>', + self.assertEquals( + '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" />', etree.tostring(mergemodule.root)) def test_add_module(self): @@ -98,7 +96,7 @@ class MergeModuleTest(unittest.TestCase): mergemodule._add_module() self.assertEquals( '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' - '<Module Id="gstreamer_test" Language="1033" Version="1.0"/>' + '<Module Id="gstreamer_test" Language="1033" Version="1.0" />' '</Wix>', etree.tostring(mergemodule.root)) def test_add_package(self): @@ -110,7 +108,7 @@ class MergeModuleTest(unittest.TestCase): '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' '<Module Id="gstreamer_test" Language="1033" Version="1.0">' '<Package Comments="test" Description="GStreamer Test" Id="1" ' - 'Manufacturer="GStreamer Project"/>' + 'Manufacturer="GStreamer Project" />' '</Module>' '</Wix>', etree.tostring(mergemodule.root)) @@ -124,8 +122,8 @@ class MergeModuleTest(unittest.TestCase): '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">' '<Module Id="gstreamer_test" Language="1033" Version="1.0">' '<Package Comments="test" Description="GStreamer Test" Id="1" ' - 'Manufacturer="GStreamer Project"/>' - '<Directory Id="TARGETDIR" Name="SourceDir"/>' + 'Manufacturer="GStreamer Project" />' + '<Directory Id="TARGETDIR" Name="SourceDir" />' '</Module>' '</Wix>', etree.tostring(mergemodule.root)) diff --git a/cerbero/utils/__init__.py b/cerbero/utils/__init__.py index 4456bcdc..9a7e01c9 100644 --- a/cerbero/utils/__init__.py +++ b/cerbero/utils/__init__.py @@ -22,6 +22,10 @@ try: import sysconfig except: from distutils import sysconfig +try: + import xml.etree.cElementTree as etree +except ImportError: + from lxml import etree import gettext import platform as pplatform |