Remove a monkey-patching workaround for python < 2.7.3
We moved way past that version. Change-Id: Ic775e8653520c10d0a87f768db20b06b698b4444
This commit is contained in:
parent
1f4fc2001d
commit
cc3a42ef22
@ -13,9 +13,6 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from sahara.utils import patches
|
||||
patches.patch_minidom_writexml()
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -33,7 +33,6 @@ from sahara.tests.unit import base
|
||||
from sahara.tests.unit.service.edp import edp_test_utils as u
|
||||
from sahara.utils import cluster as c_u
|
||||
from sahara.utils import edp
|
||||
from sahara.utils import patches as p
|
||||
from sahara.utils import xmlutils
|
||||
|
||||
conductor = cond.API
|
||||
@ -45,7 +44,6 @@ _java_opts = "-Dparam1=val1 -Dparam2=val2"
|
||||
class TestJobManager(base.SaharaWithDbTestCase):
|
||||
def setUp(self):
|
||||
super(TestJobManager, self).setUp()
|
||||
p.patch_minidom_writexml()
|
||||
self.override_config('plugins', ['fake'])
|
||||
pb.setup_plugins()
|
||||
castellan.validate_config()
|
||||
|
@ -21,14 +21,12 @@ from sahara.service.edp.oozie.workflow_creator import java_workflow as jw
|
||||
from sahara.service.edp.oozie.workflow_creator import mapreduce_workflow as mrw
|
||||
from sahara.service.edp.oozie.workflow_creator import pig_workflow as pw
|
||||
from sahara.service.edp.oozie.workflow_creator import shell_workflow as shw
|
||||
from sahara.utils import patches as p
|
||||
|
||||
|
||||
class TestWorkflowCreators(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestWorkflowCreators, self).setUp()
|
||||
p.patch_minidom_writexml()
|
||||
self.prepare = {'delete': ['delete_dir_1', 'delete_dir_2'],
|
||||
'mkdir': ['mkdir_1']}
|
||||
self.job_xml = 'job_xml.xml'
|
||||
|
@ -18,13 +18,10 @@ import xml.dom.minidom as xml
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from sahara.utils import patches
|
||||
|
||||
|
||||
class MinidomPatchesTest(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(MinidomPatchesTest, self).setUp()
|
||||
patches.patch_minidom_writexml()
|
||||
|
||||
def _generate_n_prettify_xml(self):
|
||||
doc = xml.Document()
|
||||
|
@ -18,7 +18,6 @@ import xml.dom.minidom as xml
|
||||
import pkg_resources as pkg
|
||||
import testtools
|
||||
|
||||
from sahara.utils import patches as p
|
||||
from sahara.utils import xmlutils as x
|
||||
from sahara import version
|
||||
|
||||
@ -27,7 +26,6 @@ class XMLUtilsTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(XMLUtilsTestCase, self).setUp()
|
||||
p.patch_minidom_writexml()
|
||||
|
||||
def test_load_xml_defaults(self):
|
||||
self.assertEqual(
|
||||
|
@ -29,10 +29,8 @@ def patch_all():
|
||||
List of patches:
|
||||
|
||||
* eventlet's monkey patch for all cases;
|
||||
* minidom's writexml patch for py < 2.7.3 only.
|
||||
"""
|
||||
eventlet_monkey_patch()
|
||||
patch_minidom_writexml()
|
||||
|
||||
|
||||
def eventlet_monkey_patch():
|
||||
@ -50,59 +48,3 @@ def eventlet_import_monkey_patched(module):
|
||||
It's needed for some tests, for example, context test.
|
||||
"""
|
||||
return eventlet.import_patched(module, **EVENTLET_MONKEY_PATCH_MODULES)
|
||||
|
||||
|
||||
def patch_minidom_writexml():
|
||||
"""Patch for xml.dom.minidom toprettyxml bug with whitespaces around text
|
||||
|
||||
We apply the patch to avoid excess whitespaces in generated xml
|
||||
configuration files that brakes Hadoop.
|
||||
|
||||
(This patch will be applied for all Python versions < 2.7.3)
|
||||
|
||||
Issue: http://bugs.python.org/issue4147
|
||||
Patch: http://hg.python.org/cpython/rev/cb6614e3438b/
|
||||
Description: http://ronrothman.com/public/leftbraned/xml-dom-minidom-\
|
||||
toprettyxml-and-silly-whitespace/#best-solution
|
||||
"""
|
||||
|
||||
import sys
|
||||
if sys.version_info >= (2, 7, 3):
|
||||
return
|
||||
|
||||
import xml.dom.minidom as md
|
||||
|
||||
def element_writexml(self, writer, indent="", addindent="", newl=""):
|
||||
# indent = current indentation
|
||||
# addindent = indentation to add to higher levels
|
||||
# newl = newline string
|
||||
writer.write(indent + "<" + self.tagName)
|
||||
|
||||
attrs = self._get_attributes()
|
||||
a_names = list(attrs.keys())
|
||||
a_names.sort()
|
||||
|
||||
for a_name in a_names:
|
||||
writer.write(" %s=\"" % a_name)
|
||||
md._write_data(writer, attrs[a_name].value)
|
||||
writer.write("\"")
|
||||
if self.childNodes:
|
||||
writer.write(">")
|
||||
if (len(self.childNodes) == 1
|
||||
and self.childNodes[0].nodeType == md.Node.TEXT_NODE):
|
||||
self.childNodes[0].writexml(writer, '', '', '')
|
||||
else:
|
||||
writer.write(newl)
|
||||
for node in self.childNodes:
|
||||
node.writexml(writer, indent + addindent, addindent, newl)
|
||||
writer.write(indent)
|
||||
writer.write("</%s>%s" % (self.tagName, newl))
|
||||
else:
|
||||
writer.write("/>%s" % (newl))
|
||||
|
||||
md.Element.writexml = element_writexml
|
||||
|
||||
def text_writexml(self, writer, indent="", addindent="", newl=""):
|
||||
md._write_data(writer, "%s%s%s" % (indent, self.data, newl))
|
||||
|
||||
md.Text.writexml = text_writexml
|
||||
|
Loading…
Reference in New Issue
Block a user