aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/16_test_supercommand.py
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2013-06-30 16:06:43 +0200
committerGuido Günther <agx@sigxcpu.org>2013-06-30 16:20:25 +0200
commit2145c58e8582d620d8aba0e13adc083f16c9b35e (patch)
tree03e23c15f28954de35834883075d3495424498f9 /tests/16_test_supercommand.py
parenta2ce3872d163d84290d1f8b119d4262e8ccdfdc8 (diff)
Test succesful import too
and make sure we don't spew to stderr during this test
Diffstat (limited to 'tests/16_test_supercommand.py')
-rw-r--r--tests/16_test_supercommand.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/16_test_supercommand.py b/tests/16_test_supercommand.py
index 5a9f0374..884437bc 100644
--- a/tests/16_test_supercommand.py
+++ b/tests/16_test_supercommand.py
@@ -15,12 +15,14 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Test L{gbp} command wrapper"""
+import sys
import unittest
import gbp.scripts.supercommand
class TestSuperCommand(unittest.TestCase):
def test_import(self):
+ """Test the importer itself"""
self.assertRaises(ImportError,
gbp.scripts.supercommand.import_command,
'not.allowed')
@@ -30,11 +32,22 @@ class TestSuperCommand(unittest.TestCase):
self.assertRaises(ImportError,
gbp.scripts.supercommand.import_command,
'0notallowed')
+ self.assertIsNotNone(gbp.scripts.supercommand.import_command('pq'))
def test_invalid_command(self):
- """Test if we can import a valid command"""
+ """Test if we fail correctly with an invalid command"""
+ old_stderr = sys.stderr
+ with file('/dev/null', 'w') as sys.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_help_command(self):
+ """Invoking with --help must not raise an error"""
self.assertEqual(gbp.scripts.supercommand.supercommand(
- ['argv0', 'asdf']), 2)
+ ['argv0', '--help']), 0)
def test_missing_arg(self):
self.assertEqual(gbp.scripts.supercommand.supercommand(