Port to Python 3
This should make all tests pass on both Python 2 and Python 3. Unittest2 is required on Py 2.6 and Py 3. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
3088df8e60
commit
ed22e07ef9
50 changed files with 203 additions and 208 deletions
|
|
@ -1,9 +1,8 @@
|
|||
import mock
|
||||
import unittest
|
||||
import six
|
||||
import pungi
|
||||
|
||||
from helpers import load_bin
|
||||
from tests.helpers import load_bin
|
||||
|
||||
cli = load_bin("pungi-koji")
|
||||
|
||||
|
|
@ -12,8 +11,13 @@ class PungiKojiTestCase(unittest.TestCase):
|
|||
|
||||
@mock.patch('sys.argv', new=['prog', '--version'])
|
||||
@mock.patch('sys.stderr', new_callable=six.StringIO)
|
||||
@mock.patch('sys.stdout', new_callable=six.StringIO)
|
||||
@mock.patch('pungi_cli_fake_pungi-koji.get_full_version', return_value='a-b-c.111')
|
||||
def test_version(self, get_full_version, stderr):
|
||||
def test_version(self, get_full_version, stdout, stderr):
|
||||
with self.assertRaises(SystemExit):
|
||||
cli.main()
|
||||
self.assertMultiLineEqual(stderr.getvalue(), 'a-b-c.111\n')
|
||||
# Python 2.7 prints the version to stderr, 3.4+ to stdout.
|
||||
if six.PY3:
|
||||
self.assertMultiLineEqual(stdout.getvalue(), 'a-b-c.111\n')
|
||||
else:
|
||||
self.assertMultiLineEqual(stderr.getvalue(), 'a-b-c.111\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue