14_test_gbp_import_dscs: Mock gbp.log.err
authorGuido Günther <agx@sigxcpu.org>
Fri, 26 Apr 2013 21:13:29 +0000 (23:13 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 26 Apr 2013 21:23:02 +0000 (23:23 +0200)
to get rid of the spurious error message

tests/14_test_gbp_import_dscs.py

index 694d67e..3e4772f 100644 (file)
 
 from . import context
 
-import os
 import testutils
+import gbp.log
 import gbp.scripts.import_dscs as import_dscs
 
+from gbp.errors import GbpError
 
 class StubGitImportDsc(object):
     """
@@ -55,13 +56,18 @@ def stub_parse_dsc(filename):
 import_dscs.GitImportDsc = StubGitImportDsc
 import_dscs.parse_dsc = stub_parse_dsc
 
-
 class TestImportDscs(testutils.DebianGitTestRepo):
     """Test L{gbp.scripts.import_dscs}'s """
 
     def setUp(self):
         testutils.DebianGitTestRepo.setUp(self)
         context.chdir(self.repo.path)
+        self.orig_err = gbp.log.err
+        gbp.log.err = self._check_err_msg
+
+    def _check_err_msg(self, err):
+        self.assertIsInstance(err, GbpError)
+        self.assertIn("Failed to import", err.message)
 
     def test_import_success(self):
         """Test importing success with stub"""
@@ -83,6 +89,7 @@ class TestImportDscs(testutils.DebianGitTestRepo):
         self.assertEqual(ret, 1)
 
     def tearDown(self):
+        gbp.log.err = self.orig_err
         testutils.DebianGitTestRepo.tearDown(self)
         context.teardown()