forked from openlp/openlp
Fleshed out get_filesystem_encoding_test thanks to Jonathan C
This commit is contained in:
parent
000b06ffe6
commit
9934a41d48
@ -15,7 +15,30 @@ class TestUtils(TestCase):
|
|||||||
"""
|
"""
|
||||||
Test the get_filesystem_encoding() function
|
Test the get_filesystem_encoding() function
|
||||||
"""
|
"""
|
||||||
assert False, u'This test needs to be written'
|
with patch(u'sys.getfilesystemencoding') as mocked_getfilesystemencoding, \
|
||||||
|
patch(u'sys.getdefaultencoding') as mocked_getdefaultencoding:
|
||||||
|
# GIVEN: sys.getfilesystemencoding returns "cp1252"
|
||||||
|
mocked_getfilesystemencoding.return_value = u'cp1252'
|
||||||
|
|
||||||
|
# WHEN: get_filesystem_encoding() is called
|
||||||
|
result = get_filesystem_encoding()
|
||||||
|
|
||||||
|
# THEN: getdefaultencoding should have been called
|
||||||
|
mocked_getfilesystemencoding.assert_called_with()
|
||||||
|
assert not mocked_getdefaultencoding.called
|
||||||
|
assert result == u'cp1252', u'The result should be "cp1252"'
|
||||||
|
|
||||||
|
# GIVEN: sys.getfilesystemencoding returns None and sys.getdefaultencoding returns "utf-8"
|
||||||
|
mocked_getfilesystemencoding.return_value = None
|
||||||
|
mocked_getdefaultencoding.return_value = u'utf-8'
|
||||||
|
|
||||||
|
# WHEN: get_filesystem_encoding() is called
|
||||||
|
result = get_filesystem_encoding()
|
||||||
|
|
||||||
|
# THEN: getdefaultencoding should have been called
|
||||||
|
mocked_getfilesystemencoding.assert_called_with()
|
||||||
|
mocked_getdefaultencoding.assert_called_with()
|
||||||
|
assert result == u'utf-8', u'The result should be "utf-8"'
|
||||||
|
|
||||||
def get_frozen_path_test(self):
|
def get_frozen_path_test(self):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user