Skip to content

Commit

Permalink
Improve test assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgoce committed Mar 19, 2015
1 parent edc08bc commit baf614a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/tests.py
@@ -1,5 +1,6 @@
import os
import unittest
import xml.dom.minidom

from junit_conversor import _parse, _convert

Expand Down Expand Up @@ -52,6 +53,18 @@ def setUp(self):
except OSError:
pass

def assertXmlIsValid(self, xml_file):
try:
with file(xml_file) as f:
content = f.read()

xml.dom.minidom.parseString(content)
except xml.parsers.expat.ExpatError:
raise Exception('The specified file is not a valid XML (%s)'
% content[0:30])

def test_can_convert_a_file_to_junit_xml(self):
_convert(failed_flake8, self.destination)

self.assertTrue(os.path.exists(self.destination), 'The xml file should exist')
self.assertXmlIsValid(self.destination)

0 comments on commit baf614a

Please sign in to comment.