Unittests: Fix warnings
- Replace deprecated assertion-aliases - Make sure opened files are properly closed after usage
This commit is contained in:
parent
320bdda6e9
commit
c54c5e5d7e
3 changed files with 263 additions and 247 deletions
|
|
@ -3095,7 +3095,8 @@ def scourString(in_string, options=None):
|
||||||
# input is a filename
|
# input is a filename
|
||||||
# returns the minidom doc representation of the SVG
|
# returns the minidom doc representation of the SVG
|
||||||
def scourXmlFile(filename, options=None):
|
def scourXmlFile(filename, options=None):
|
||||||
in_string = open(filename).read()
|
with open(filename) as f:
|
||||||
|
in_string = f.read()
|
||||||
out_string = scourString(in_string, options)
|
out_string = scourString(in_string, options)
|
||||||
return xml.dom.minidom.parseString(out_string.encode('utf-8'))
|
return xml.dom.minidom.parseString(out_string.encode('utf-8'))
|
||||||
|
|
||||||
|
|
|
||||||
18
testcss.py
18
testcss.py
|
|
@ -29,23 +29,23 @@ from scour.yocto_css import parseCssString
|
||||||
class Blank(unittest.TestCase):
|
class Blank(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
r = parseCssString('')
|
r = parseCssString('')
|
||||||
self.assertEquals( len(r), 0, 'Blank string returned non-empty list')
|
self.assertEqual( len(r), 0, 'Blank string returned non-empty list')
|
||||||
self.assertEquals( type(r), type([]), 'Blank string returned non list')
|
self.assertEqual( type(r), type([]), 'Blank string returned non list')
|
||||||
|
|
||||||
class ElementSelector(unittest.TestCase):
|
class ElementSelector(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
r = parseCssString('foo {}')
|
r = parseCssString('foo {}')
|
||||||
self.assertEquals( len(r), 1, 'Element selector not returned')
|
self.assertEqual( len(r), 1, 'Element selector not returned')
|
||||||
self.assertEquals( r[0]['selector'], 'foo', 'Selector for foo not returned')
|
self.assertEqual( r[0]['selector'], 'foo', 'Selector for foo not returned')
|
||||||
self.assertEquals( len(r[0]['properties']), 0, 'Property list for foo not empty')
|
self.assertEqual( len(r[0]['properties']), 0, 'Property list for foo not empty')
|
||||||
|
|
||||||
class ElementSelectorWithProperty(unittest.TestCase):
|
class ElementSelectorWithProperty(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
||||||
r = parseCssString('foo { bar: baz}')
|
r = parseCssString('foo { bar: baz}')
|
||||||
self.assertEquals( len(r), 1, 'Element selector not returned')
|
self.assertEqual( len(r), 1, 'Element selector not returned')
|
||||||
self.assertEquals( r[0]['selector'], 'foo', 'Selector for foo not returned')
|
self.assertEqual( r[0]['selector'], 'foo', 'Selector for foo not returned')
|
||||||
self.assertEquals( len(r[0]['properties']), 1, 'Property list for foo did not have 1')
|
self.assertEqual( len(r[0]['properties']), 1, 'Property list for foo did not have 1')
|
||||||
self.assertEquals( r[0]['properties']['bar'], 'baz', 'Property bar did not have baz value')
|
self.assertEqual( r[0]['properties']['bar'], 'baz', 'Property bar did not have baz value')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
489
testscour.py
489
testscour.py
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue