[Reportbug-commits] [SCM] Reportbug - reports bugs in the Debian distribution branch, master, updated. 6.0-101-gde75f77

Sandro Tosi morph at debian.org
Fri Apr 6 23:45:26 UTC 2012


The following commit has been merged in the master branch:
commit 3355f3990721386621fa438b25376f2f5f746fe8
Author: Sandro Tosi <morph at debian.org>
Date:   Wed Apr 4 20:38:29 2012 +0200

    extend debbugs.dpkg_infofunc() tests
    
    Using mock objects we can test also special branches. Using them it was also
    fixed
    
      UnboundLocalError: local variable 'utsmachine' referenced before assignment
    
    in case utils.get_arch() returns nothing.

diff --git a/reportbug/debbugs.py b/reportbug/debbugs.py
index 2529062..a8244bd 100644
--- a/reportbug/debbugs.py
+++ b/reportbug/debbugs.py
@@ -650,8 +650,8 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
 
 def dpkg_infofunc():
     debarch = utils.get_arch()
+    utsmachine = os.uname()[4]
     if debarch:
-        utsmachine = os.uname()[4]
         if utsmachine == debarch:
             debinfo = u'Architecture: %s\n\n' % debarch
         else:
diff --git a/test/test_debbugs.py b/test/test_debbugs.py
index ecf6880..57575be 100644
--- a/test/test_debbugs.py
+++ b/test/test_debbugs.py
@@ -1,6 +1,7 @@
 import unittest2
 
 from nose.plugins.attrib import attr
+import mock
 
 from reportbug import utils
 from reportbug import debbugs
@@ -59,6 +60,18 @@ class TestInfofunc(unittest2.TestCase):
     def test_dpkg_infofunc(self):
         info = debbugs.dpkg_infofunc()
         self.assertIn('Architecture:', info)
+        self.assertTrue(info.endswith('\n\n'))
+
+        utils.get_arch = mock.MagicMock(return_value = 'non-existing-arch')
+        info = debbugs.dpkg_infofunc()
+        self.assertIn('non-existing-arch', info)
+        self.assertTrue(info.endswith('\n\n'))
+
+        # test with get_arch() returning None
+        utils.get_arch = mock.MagicMock(return_value = None)
+        info = debbugs.dpkg_infofunc()
+        self.assertIn('Architecture: ?', info)
+        self.assertTrue(info.endswith('\n\n'))
 
     def test_debian_infofunc(self):
         info = debbugs.debian_infofunc()

-- 
Reportbug - reports bugs in the Debian distribution



More information about the Reportbug-commits mailing list