The library is imported if available, but we never build it in any environment where the package would be installed. It was last used for RHEL 6 builds. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com> (cherry picked from commit d95d1f59e2ae243ea794c5f5613fef3249b4fad6)
23 lines
830 B
Python
23 lines
830 B
Python
from unittest import mock
|
|
|
|
import unittest
|
|
import six
|
|
|
|
from pungi.scripts.pungi_koji import cli_main
|
|
|
|
|
|
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.scripts.pungi_koji.get_full_version", return_value="a-b-c.111")
|
|
def test_version(self, get_full_version, stdout, stderr):
|
|
with self.assertRaises(SystemExit) as cm:
|
|
cli_main()
|
|
self.assertEqual(cm.exception.code, 0)
|
|
# 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")
|