Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
check xml as binary encoded string
Browse files Browse the repository at this point in the history
  • Loading branch information
ruleant committed Jan 25, 2015
1 parent f26ac37 commit edae422
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
36 changes: 18 additions & 18 deletions buildtimetrend/test/build_test.py
Expand Up @@ -55,11 +55,11 @@ def test_novalue(self):

# xml shouldn't contain items
self.assertEquals(
'<build><stages/></build>', etree.tostring(self.build.to_xml()))
b'<build><stages/></build>', etree.tostring(self.build.to_xml()))
self.assertEquals(
'<build>\n'
' <stages/>\n'
'</build>\n', self.build.to_xml_string())
b'<build>\n'
b' <stages/>\n'
b'</build>\n', self.build.to_xml_string())

def test_nofile(self):
# number of stages should be zero when file doesn't exist
Expand Down Expand Up @@ -379,20 +379,20 @@ def test_to_xml(self):

# test xml output
self.assertEquals(
'<build><stages><stage duration="2.0" name="stage1"/>'
'<stage duration="5.0" name="stage2"/>'
'<stage duration="10.0" name="stage3"/></stages></build>',
b'<build><stages><stage duration="2.0" name="stage1"/>'
b'<stage duration="5.0" name="stage2"/>'
b'<stage duration="10.0" name="stage3"/></stages></build>',
etree.tostring(self.build.to_xml()))

# add properties
self.build.add_property('property1', 2)
self.build.add_property('property2', 3)
# test xml output
self.assertEquals(
'<build property1="2" property2="3">'
'<stages><stage duration="2.0" name="stage1"/>'
'<stage duration="5.0" name="stage2"/>'
'<stage duration="10.0" name="stage3"/></stages></build>',
b'<build property1="2" property2="3">'
b'<stages><stage duration="2.0" name="stage1"/>'
b'<stage duration="5.0" name="stage2"/>'
b'<stage duration="10.0" name="stage3"/></stages></build>',
etree.tostring(self.build.to_xml()))

def test_to_xml_string(self):
Expand All @@ -401,13 +401,13 @@ def test_to_xml_string(self):

# test xml string output
self.assertEquals(
'<build>\n'
' <stages>\n'
' <stage duration="2.0" name="stage1"/>\n'
' <stage duration="5.0" name="stage2"/>\n'
' <stage duration="10.0" name="stage3"/>\n'
' </stages>\n'
'</build>\n',
b'<build>\n'
b' <stages>\n'
b' <stage duration="2.0" name="stage1"/>\n'
b' <stage duration="5.0" name="stage2"/>\n'
b' <stage duration="10.0" name="stage3"/>\n'
b' </stages>\n'
b'</build>\n',
self.build.to_xml_string())

# add properties
Expand Down
20 changes: 10 additions & 10 deletions buildtimetrend/test/stages_test.py
Expand Up @@ -47,8 +47,8 @@ def test_novalue(self):
self.assertEqual(None, self.stages.started_at)
self.assertEqual(None, self.stages.finished_at)
# xml shouldn't contain items
self.assertEquals("<stages/>", etree.tostring(self.stages.to_xml()))
self.assertEquals("<stages/>\n", self.stages.to_xml_string())
self.assertEquals(b"<stages/>", etree.tostring(self.stages.to_xml()))
self.assertEquals(b"<stages/>\n", self.stages.to_xml_string())

def test_nofile(self):
# function should return false when file doesn't exist
Expand Down Expand Up @@ -242,9 +242,9 @@ def test_to_xml(self):

# test xml output
self.assertEquals(
'<stages><stage duration="2.0" name="stage1"/>'
'<stage duration="5.0" name="stage2"/>'
'<stage duration="10.0" name="stage3"/></stages>',
b'<stages><stage duration="2.0" name="stage1"/>'
b'<stage duration="5.0" name="stage2"/>'
b'<stage duration="10.0" name="stage3"/></stages>',
etree.tostring(self.stages.to_xml()))

def test_to_xml_string(self):
Expand All @@ -253,11 +253,11 @@ def test_to_xml_string(self):

# test xml string output
self.assertEquals(
'<stages>\n'
' <stage duration="2.0" name="stage1"/>\n'
' <stage duration="5.0" name="stage2"/>\n'
' <stage duration="10.0" name="stage3"/>\n'
'</stages>\n',
b'<stages>\n'
b' <stage duration="2.0" name="stage1"/>\n'
b' <stage duration="5.0" name="stage2"/>\n'
b' <stage duration="10.0" name="stage3"/>\n'
b'</stages>\n',
self.stages.to_xml_string())

def test_add_stage(self):
Expand Down

0 comments on commit edae422

Please sign in to comment.