diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-12-26 20:15:17 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-12-26 20:15:17 +0100 |
commit | 9e44a205fbec7fd83ff4c41fa17a7e4c049ef1ba (patch) | |
tree | befe94e0de99d3994ee0c9b06ffa2862df830e38 /tests/16_test_supercommand.py | |
parent | 6382d56b09f88a1d9d62baf8c7969703126b6672 (diff) |
test_supercommand: test --list-cmds
Diffstat (limited to 'tests/16_test_supercommand.py')
-rw-r--r-- | tests/16_test_supercommand.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/16_test_supercommand.py b/tests/16_test_supercommand.py index 65f4b105..d15ec797 100644 --- a/tests/16_test_supercommand.py +++ b/tests/16_test_supercommand.py @@ -15,10 +15,11 @@ # <http://www.gnu.org/licenses/> """Test L{gbp} command wrapper""" -import sys import unittest import gbp.scripts.supercommand +from tests.testutils import capture_stdout, capture_stderr + class TestSuperCommand(unittest.TestCase): @@ -37,13 +38,19 @@ class TestSuperCommand(unittest.TestCase): def test_invalid_command(self): """Test if we fail correctly with an invalid command""" - old_stderr = sys.stderr - with open('/dev/null', 'w') as sys.stderr: + with capture_stderr(): self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0', 'asdf']), 2) self.assertEqual(gbp.scripts.supercommand.supercommand( ['argv0', 'asdf', '--verbose']), 2) - sys.stderr = old_stderr + + def test_list_commands(self): + """Invoking with --list-cmds must not raise an error""" + with capture_stdout() as out: + self.assertEqual(gbp.scripts.supercommand.supercommand(['argv0', + '--list-cmds']), 0) + for cmd in ['import-orig', 'create-remote-repo', 'pq']: + self.assertIn("%s - " % cmd, out.output()) def test_help_command(self): """Invoking with --help must not raise an error""" |