Fix pungi-koji --version
Signed-off-by: dowang <dowang@redhat.com>
This commit is contained in:
parent
3ef2a65275
commit
adaab46bf7
@ -130,7 +130,8 @@ def main():
|
||||
)
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
action="store_true",
|
||||
action="version",
|
||||
version=get_full_version(),
|
||||
help="output version information and exit",
|
||||
)
|
||||
parser.add_argument(
|
||||
@ -173,10 +174,6 @@ def main():
|
||||
fail_to_start(msg)
|
||||
parser.error(msg)
|
||||
|
||||
if opts.version:
|
||||
print("pungi %s" % get_full_version())
|
||||
sys.exit(0)
|
||||
|
||||
if opts.target_dir and not opts.compose_dir:
|
||||
opts.target_dir = os.path.abspath(opts.target_dir)
|
||||
if not os.path.isdir(opts.target_dir):
|
||||
|
@ -9,6 +9,7 @@ except ImportError:
|
||||
import tempfile
|
||||
import shutil
|
||||
import errno
|
||||
import imp
|
||||
|
||||
from pungi.util import get_arch_variant_data
|
||||
from pungi import paths, checks
|
||||
@ -190,3 +191,7 @@ def load_config(data={}, **kwargs):
|
||||
conf.update(data)
|
||||
conf.update(kwargs)
|
||||
return conf
|
||||
|
||||
|
||||
def load_bin(name):
|
||||
return imp.load_source('pungi_cli_fake_' + name, os.path.dirname(__file__) + "/../bin/" + name)
|
19
tests/test_arguments.py
Normal file
19
tests/test_arguments.py
Normal file
@ -0,0 +1,19 @@
|
||||
import mock
|
||||
import unittest
|
||||
import six
|
||||
import pungi
|
||||
|
||||
from helpers import load_bin
|
||||
|
||||
cli = load_bin("pungi-koji")
|
||||
|
||||
|
||||
class PungiKojiTestCase(unittest.TestCase):
|
||||
|
||||
@mock.patch('sys.argv', new=['prog', '--version'])
|
||||
@mock.patch('sys.stderr', 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):
|
||||
with self.assertRaises(SystemExit):
|
||||
cli.main()
|
||||
self.assertMultiLineEqual(stderr.getvalue(), 'a-b-c.111\n')
|
Loading…
Reference in New Issue
Block a user