summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2017-02-16 02:12:52 -0500
committerMike Frysinger <vapier@gentoo.org>2017-02-16 02:12:52 -0500
commitc688fa044b7b5e8e72ae6e9cc7f54fc35e1ff0c1 (patch)
tree8fa8617e099ae4eef3d8d72ec0dfc2095d55b82a
parentechangelog: Add fallback text in case skel.ChangeLog is missing (diff)
downloadgentoolkit-c688fa044b7b5e8e72ae6e9cc7f54fc35e1ff0c1.tar.gz
gentoolkit-c688fa044b7b5e8e72ae6e9cc7f54fc35e1ff0c1.tar.bz2
gentoolkit-c688fa044b7b5e8e72ae6e9cc7f54fc35e1ff0c1.zip
ekeyword: change --version to use builtin version action
Minor clean up here.
-rwxr-xr-xsrc/ekeyword/ekeyword.py5
-rwxr-xr-xsrc/ekeyword/ekeyword_unittest.py11
2 files changed, 9 insertions, 7 deletions
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py
index e4a8197..a36dcd3 100755
--- a/src/ekeyword/ekeyword.py
+++ b/src/ekeyword/ekeyword.py
@@ -459,7 +459,7 @@ def get_parser():
parser.add_argument('--format', default='auto', dest='style',
choices=('auto', 'color-inline', 'inline', 'short-multi', 'long-multi'),
help='Selet output format for showing differences')
- parser.add_argument('-V', '--version', default=False, action='store_true',
+ parser.add_argument('-V', '--version', action='version', version=VERSION,
help='Show version information')
return parser
@@ -493,9 +493,6 @@ def main(argv):
parser = get_parser()
opts = parser.parse_args(parse_args)
- if opts.version:
- print('version: %s' % VERSION)
- return os.EX_OK
if not work_args:
parser.error('need arches/ebuilds to process')
diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py
index 473113b..7b9017e 100755
--- a/src/ekeyword/ekeyword_unittest.py
+++ b/src/ekeyword/ekeyword_unittest.py
@@ -378,11 +378,16 @@ class TestMain(unittest.TestCase):
def testSmoke(self):
ekeyword.main(['arm', '--dry-run', os.path.join(TESTDIR, 'process-1.ebuild')])
- ekeyword.main(['--version', '--dry-run'])
+
+ def testVersion(self):
+ with self.assertRaises(SystemExit) as e:
+ ekeyword.main(['--version', '--dry-run'])
+ self.assertEqual(e.exception.code, os.EX_OK)
def testEmptyString(self):
- self.assertRaises(SystemExit, ekeyword.main,
- ['', os.path.join(TESTDIR, 'process-1.ebuild')])
+ with self.assertRaises(SystemExit) as e:
+ ekeyword.main(['', os.path.join(TESTDIR, 'process-1.ebuild')])
+ self.assertNotEqual(e.exception.code, os.EX_OK)
if __name__ == '__main__':