test write_file.
This commit is contained in:
parent
c64b50aba8
commit
6c5f7c5f4d
2 changed files with 13 additions and 1 deletions
|
@ -338,4 +338,5 @@ def write_file(filename, content):
|
|||
:param filename: filename to write to
|
||||
:param content: content to write
|
||||
"""
|
||||
codecs.open(filename, 'w', 'utf-8').write(content)
|
||||
with codecs.open(filename, 'w', 'utf-8') as afile:
|
||||
afile.write(content)
|
||||
|
|
|
@ -66,3 +66,14 @@ class TestHashstore(unittest.TestCase):
|
|||
self.hashstore.hashfile('hashme.txt')
|
||||
)
|
||||
os.remove('hashme.txt')
|
||||
|
||||
|
||||
class TestStaticMethods(unittest.TestCase):
|
||||
def test_write_file(self):
|
||||
blogtopoid.write_file('testfilename.txt', '1234')
|
||||
|
||||
with codecs.open('testfilename.txt', 'r', 'utf8') as afile:
|
||||
contents = afile.read()
|
||||
self.assertEqual('1234', contents)
|
||||
|
||||
os.remove('testfilename.txt')
|
||||
|
|
Reference in a new issue