def test_update_regular_file(self): fileobj, filename = tempfile.mkstemp(suffix=".py", text=True) # setup with open(filename, "w") as fileobj: fileobj.write("This is a test of the emergency {broadcast} system.") create.update_file(filename, {"broadcast": "kitten"}) with open(filename, "r") as fileobj: result = fileobj.read() self.assertEqual("This is a test of the emergency kitten system.", result)
def test_update_regular_file(self): fileobj, filename = tempfile.mkstemp(suffix='.py', text=True) # setup with open(filename, 'w') as fileobj: fileobj.write('This is a test of the emergency {broadcast} system.') create.update_file(filename, {'broadcast': 'kitten'}) with open(filename, 'r') as fileobj: result = fileobj.read() self.assertEqual('This is a test of the emergency kitten system.', result)
def test_update_xml_file(self): fileobj, filename = tempfile.mkstemp(suffix=".xml", text=True) print filename # setup with open(filename, "w") as fileobj: fileobj.write("<tag provider={provider}/>") create.update_file(filename, {"provider": "name aka \"another name\" <*****@*****.**> 'foo'"}) with open(filename, "r") as fileobj: result = fileobj.read() expected = "<tag provider=\"name aka "another name" <[email protected]> 'foo'\"/>" self.assertEqual(expected, result)
def test_update_regular_file(self): fileobj, filename = tempfile.mkstemp(suffix='.py', text=True) # setup with open(filename, 'w') as fileobj: fileobj.write( 'This is a test of the emergency {broadcast} system.') create.update_file(filename, {'broadcast': 'kitten'}) with open(filename, 'r') as fileobj: result = fileobj.read() self.assertEqual('This is a test of the emergency kitten system.', result)
def test_update_xml_file(self): fileobj, filename = tempfile.mkstemp(suffix='addon.xml', text=True) print filename # setup with open(filename, 'w') as fileobj: fileobj.write('<tag provider={provider}/>') create.update_file(filename, {'provider': 'name aka "another name" <*****@*****.**> \'foo\''}) with open(filename, 'r') as fileobj: result = fileobj.read() expected = '<tag provider="name aka "another name" <[email protected]> \'foo\'"/>' self.assertEqual(expected, result)
def test_update_xml_file(self): fileobj, filename = tempfile.mkstemp(suffix='addon.xml', text=True) print filename # setup with open(filename, 'w') as fileobj: fileobj.write('<tag provider={provider}/>') create.update_file( filename, {'provider': 'name aka "another name" <*****@*****.**> \'foo\''}) with open(filename, 'r') as fileobj: result = fileobj.read() expected = '<tag provider="name aka "another name" <[email protected]> \'foo\'"/>' self.assertEqual(expected, result)