[Reportbug-commits] [reportbug] 01/02: Save and restore mocked methods

Sandro Tosi morph at moszumanska.debian.org
Fri Nov 7 14:18:20 UTC 2014


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository reportbug.

commit e6dc48c644241c48d0c4a1467b0040e109130133
Author: Sandro Tosi <morph at debian.org>
Date:   Fri Nov 7 11:48:14 2014 +0000

    Save and restore mocked methods
    
    This prevents to expose those mocked methods to other tests and thus result in
    unexpected failures
---
 test/test_debbugs.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/test/test_debbugs.py b/test/test_debbugs.py
index 473bcff..f858e66 100644
--- a/test/test_debbugs.py
+++ b/test/test_debbugs.py
@@ -2,7 +2,6 @@ import unittest2
 
 from nose.plugins.attrib import attr
 import mock
-
 from reportbug import utils
 from reportbug import debbugs
 
@@ -65,6 +64,10 @@ class TestInfofunc(unittest2.TestCase):
         self.assertIn('Architecture: ' + arch, info)
         self.assertTrue(info.endswith('\n\n'))
 
+        # save original method
+        __save1 = utils.get_arch
+        __save2 = utils.get_multiarch
+
         utils.get_arch = mock.MagicMock(return_value = 'non-existing-arch')
         info = debbugs.dpkg_infofunc()
         self.assertIn('non-existing-arch', info)
@@ -83,6 +86,11 @@ class TestInfofunc(unittest2.TestCase):
         self.assertIn('multi-arch-ified', info)
         self.assertIn('Foreign Architectures: multi-arch-ified', info)
 
+        utils.get_arch = __save1
+        utils.get_multiarch = __save2
+        del __save1
+        del __save2
+
     def test_debian_infofunc(self):
         info = debbugs.debian_infofunc()
         self.assertIn('Architecture:', info)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git



More information about the Reportbug-commits mailing list