cli: fix changelog encode for PY3
relates [issue#577](https://pagure.io/koji/issue/577)
This commit is contained in:
parent
ac2d2c5935
commit
3464adae2e
3 changed files with 35 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ from __future__ import absolute_import
|
|||
import koji
|
||||
import six
|
||||
import unittest
|
||||
import mock
|
||||
|
||||
class FixEncodingTestCase(unittest.TestCase):
|
||||
"""Main test case container"""
|
||||
|
|
@ -44,6 +45,23 @@ class FixEncodingTestCase(unittest.TestCase):
|
|||
d = a[:-3] + u'\x00\x01' + a[-3:]
|
||||
self.assertEqual(koji.fixEncoding(d, remove_nonprintable=True), b)
|
||||
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
def test_fixPrint(self, stdout):
|
||||
"""Test the fixPrint function"""
|
||||
expected = ''
|
||||
for a, b in self.simple_values:
|
||||
if six.PY3:
|
||||
self.assertEqual(koji.fixPrint(b), a)
|
||||
else:
|
||||
self.assertEqual(koji.fixPrint(b), b)
|
||||
print(koji.fixPrint(b))
|
||||
if six.PY3:
|
||||
expected = expected + a + '\n'
|
||||
else:
|
||||
expected = expected + b + '\n'
|
||||
actual = stdout.getvalue()
|
||||
self.assertEqual(actual, expected)
|
||||
|
||||
complex_values = [
|
||||
# [ value, fixed ]
|
||||
[{}, {}],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue