Test help output by importing the modules
authorGuido Günther <agx@sigxcpu.org>
Wed, 1 Aug 2012 13:28:27 +0000 (15:28 +0200)
committerGuido Günther <agx@sigxcpu.org>
Wed, 1 Aug 2012 13:32:20 +0000 (15:32 +0200)
so we get correct coverage information for the scripts

tests/01_test_help.py

index 1974c30..e30bc45 100644 (file)
@@ -7,16 +7,20 @@ import unittest
 
 class TestHelp(unittest.TestCase):
     """Test help output of gbp commands"""
-    os.environ['PYTHONPATH'] = '.'
 
     def testHelp(self):
-        for prog in [ "buildpackage", "import-orig", "import-dsc", "dch" ]:
-            ret = os.system("bin/git-%s --help >/dev/null" % prog)
-            self.assertEqual(ret, 0)
-
-    def testHelpGbp(self):
-        for prog in [ "pull", "clone", "pq", "create-remote-repo" ]:
-            ret = os.system("bin/gbp-%s --help >/dev/null" % prog)
-            self.assertEqual(ret, 0)
+        for script in ['buildpackage',
+                      'clone',
+                      'create_remote_repo',
+                      'dch',
+                      'import_orig',
+                      'import_dsc',
+                      'pull',
+                      'pq']:
+            module = 'gbp.scripts.%s' % script
+            m = __import__(module, globals(), locals(), ['main'], -1)
+            self.assertRaises(SystemExit,
+                              m.main,
+                              ['doesnotmatter', '--help'])
 
 # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: