libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject libcloud git commit: Update setup.py test target so it throws an actual exception if the test module failes to load.
Date Sun, 27 Sep 2015 12:37:17 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk ecbaa0b57 -> 011d16c38


Update setup.py test target so it throws an actual exception if the test module
failes to load.

Previously, unhelpful "'module' object has no attribute" error was thrown.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/011d16c3
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/011d16c3
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/011d16c3

Branch: refs/heads/trunk
Commit: 011d16c38b22a9c6c64137aef408b3cff9e8d2ae
Parents: ecbaa0b
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Sun Sep 27 14:30:38 2015 +0200
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Sun Sep 27 14:30:38 2015 +0200

----------------------------------------------------------------------
 setup.py | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/011d16c3/setup.py
----------------------------------------------------------------------
diff --git a/setup.py b/setup.py
index 2947aa8..17a3ecc 100644
--- a/setup.py
+++ b/setup.py
@@ -176,6 +176,18 @@ class TestCommand(Command):
                 testfiles.append('.'.join(
                     [test_path.replace('/', '.'), splitext(basename(t))[0]]))
 
+        # Test loader simply throws "'module' object has no attribute" error
+        # if there is an issue with the test module so we manually try to
+        # import each module so we get a better and more friendly error message
+        for test_file in testfiles:
+            try:
+                __import__(test_file)
+            except Exception:
+                e = sys.exc_info()[1]
+                print('Failed to import test module "%s": %s' % (test_file,
+                                                                 str(e)))
+                raise e
+
         tests = TestLoader().loadTestsFromNames(testfiles)
 
         for test_module in DOC_TEST_MODULES:


Mime
View raw message