Fix tests with coverage

Mocking global sys.getfilesystemencoding affects coverage too. This
patch mocks sys only for utils module.

Change-Id: I0bd383be5de3c34a606a3c5e1d49fadd1178e070
Closes-Bug: #1525277
This commit is contained in:
Nikita Zubkov
2016-04-28 20:07:55 +03:00
parent 46c84c105f
commit 261c8b0731

View File

@@ -222,8 +222,10 @@ class TestUtils(base.UnitTestCase):
self.assertIsInstance(result, six.text_type)
self.assertEqual(result, expected_data)
@mock.patch('sys.getfilesystemencoding', return_value='iso-8859-16')
def test_latin_str_to_unicode(self, _):
@mock.patch('fuelclient.utils.sys')
def test_latin_str_to_unicode(self, sys_mock):
sys_mock.getfilesystemencoding.return_value = 'iso-8859-16'
test_data = 'czegoś' if six.PY3 else u'czegoś'.encode('iso-8859-16')
expected_data = test_data if six.PY3 else u'czegoś'
result = utils.str_to_unicode(test_data)