]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/test/test_import.py
Don't show scary diagnostic warnings from --version[-and-path] (corrected). refs...
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / test / test_import.py
index 287c4f5a13e8e94a8dcad61cfed107309ed1f3ac..b34012d61e05b56d15420e34c40333a370dccaea 100644 (file)
@@ -8,19 +8,22 @@ import __builtin__
 
 class T(unittest.TestCase):
     def test_report_import_error(self):
+        marker = "wheeeyo"
         real_import_func = __import__
         def raiseIE_from_this_particular_func(name, *args):
             if name == "foolscap":
-                marker = "wheeeyo"
                 raise ImportError(marker + " foolscap cant be imported")
             else:
                 return real_import_func(name, *args)
 
         # Let's run as little code as possible with __import__ patched.
         patcher = MonkeyPatcher((__builtin__, '__import__', raiseIE_from_this_particular_func))
-        vers_and_locs = patcher.runWithPatches(allmydata.get_package_versions_and_locations)
+        vers_and_locs, errors = patcher.runWithPatches(allmydata.get_package_versions_and_locations)
 
-        for (pkgname, stuff) in vers_and_locs:
-            if pkgname == 'foolscap':
-                self.failUnless('wheeeyo' in str(stuff[2]), stuff)
-                self.failUnless('raiseIE_from_this_particular_func' in str(stuff[2]), stuff)
+        foolscap_stuffs = [stuff for (pkg, stuff) in vers_and_locs if pkg == 'foolscap']
+        self.failUnlessEqual(len(foolscap_stuffs), 1)
+        comment = str(foolscap_stuffs[0][2])
+        self.failUnlessIn(marker, comment)
+        self.failUnlessIn('raiseIE_from_this_particular_func', comment)
+
+        self.failUnless([e for e in errors if "dependency \'foolscap\' could not be imported" in e])