From a09d7300e022dd51bd9380cd1776f7ed6aab7ebe Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Sun, 10 Apr 2011 08:58:44 -0700
Subject: [PATCH] tests: add test for including the ImportError message and
 traceback entry in the summary of errors from importing dependencies. refs
 #1389

---
 .../test/test_package_initialization.py       | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 src/allmydata/test/test_package_initialization.py

diff --git a/src/allmydata/test/test_package_initialization.py b/src/allmydata/test/test_package_initialization.py
new file mode 100644
index 00000000..6ca7edfd
--- /dev/null
+++ b/src/allmydata/test/test_package_initialization.py
@@ -0,0 +1,25 @@
+
+from twisted.trial import unittest
+
+import allmydata
+import mock
+
+real_import_func = __import__
+
+class T(unittest.TestCase):
+    @mock.patch('__builtin__.__import__')
+    def test_report_import_error(self, mockimport):
+        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)
+
+        mockimport.side_effect = raiseIE_from_this_particular_func
+
+        vers_and_locs =  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)
-- 
2.45.2