1 |
commit: c688fa044b7b5e8e72ae6e9cc7f54fc35e1ff0c1 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Feb 16 07:12:52 2017 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Feb 16 07:12:52 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=c688fa04 |
7 |
|
8 |
ekeyword: change --version to use builtin version action |
9 |
|
10 |
Minor clean up here. |
11 |
|
12 |
src/ekeyword/ekeyword.py | 5 +---- |
13 |
src/ekeyword/ekeyword_unittest.py | 11 ++++++++--- |
14 |
2 files changed, 9 insertions(+), 7 deletions(-) |
15 |
|
16 |
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py |
17 |
index e4a8197..a36dcd3 100755 |
18 |
--- a/src/ekeyword/ekeyword.py |
19 |
+++ b/src/ekeyword/ekeyword.py |
20 |
@@ -459,7 +459,7 @@ def get_parser(): |
21 |
parser.add_argument('--format', default='auto', dest='style', |
22 |
choices=('auto', 'color-inline', 'inline', 'short-multi', 'long-multi'), |
23 |
help='Selet output format for showing differences') |
24 |
- parser.add_argument('-V', '--version', default=False, action='store_true', |
25 |
+ parser.add_argument('-V', '--version', action='version', version=VERSION, |
26 |
help='Show version information') |
27 |
return parser |
28 |
|
29 |
@@ -493,9 +493,6 @@ def main(argv): |
30 |
|
31 |
parser = get_parser() |
32 |
opts = parser.parse_args(parse_args) |
33 |
- if opts.version: |
34 |
- print('version: %s' % VERSION) |
35 |
- return os.EX_OK |
36 |
if not work_args: |
37 |
parser.error('need arches/ebuilds to process') |
38 |
|
39 |
|
40 |
diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py |
41 |
index 473113b..7b9017e 100755 |
42 |
--- a/src/ekeyword/ekeyword_unittest.py |
43 |
+++ b/src/ekeyword/ekeyword_unittest.py |
44 |
@@ -378,11 +378,16 @@ class TestMain(unittest.TestCase): |
45 |
|
46 |
def testSmoke(self): |
47 |
ekeyword.main(['arm', '--dry-run', os.path.join(TESTDIR, 'process-1.ebuild')]) |
48 |
- ekeyword.main(['--version', '--dry-run']) |
49 |
+ |
50 |
+ def testVersion(self): |
51 |
+ with self.assertRaises(SystemExit) as e: |
52 |
+ ekeyword.main(['--version', '--dry-run']) |
53 |
+ self.assertEqual(e.exception.code, os.EX_OK) |
54 |
|
55 |
def testEmptyString(self): |
56 |
- self.assertRaises(SystemExit, ekeyword.main, |
57 |
- ['', os.path.join(TESTDIR, 'process-1.ebuild')]) |
58 |
+ with self.assertRaises(SystemExit) as e: |
59 |
+ ekeyword.main(['', os.path.join(TESTDIR, 'process-1.ebuild')]) |
60 |
+ self.assertNotEqual(e.exception.code, os.EX_OK) |
61 |
|
62 |
|
63 |
if __name__ == '__main__': |