You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/10/09 08:50:54 UTC
[08/10] libcloud git commit: added type to error and added test
added type to error and added test
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/7db284c6
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/7db284c6
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/7db284c6
Branch: refs/heads/trunk
Commit: 7db284c6b5bbd021361fd98bc2fbe1a783ad4d2b
Parents: 7a1bb84
Author: Anthony Shaw <an...@apache.org>
Authored: Fri Jul 1 16:19:30 2016 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jul 1 16:19:30 2016 +1000
----------------------------------------------------------------------
libcloud/base.py | 6 +++---
libcloud/test/test_init.py | 5 +++++
2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7db284c6/libcloud/base.py
----------------------------------------------------------------------
diff --git a/libcloud/base.py b/libcloud/base.py
index 6491f98..94e9f17 100644
--- a/libcloud/base.py
+++ b/libcloud/base.py
@@ -64,8 +64,8 @@ DriverTypeFactoryMap = {
class DriverTypeNotFoundError(KeyError):
- def __init__(self):
- self.message = "Driver type not found."
+ def __init__(self, type):
+ self.message = "Driver type '%s' not found." % type
def __repr__(self):
return self.message
@@ -78,4 +78,4 @@ def get_driver(type, provider):
try:
return DriverTypeFactoryMap[type](provider)
except KeyError:
- raise DriverTypeNotFoundError()
+ raise DriverTypeNotFoundError(type)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/7db284c6/libcloud/test/test_init.py
----------------------------------------------------------------------
diff --git a/libcloud/test/test_init.py b/libcloud/test/test_init.py
index 0276850..97beacc 100644
--- a/libcloud/test/test_init.py
+++ b/libcloud/test/test_init.py
@@ -26,6 +26,7 @@ except ImportError:
import libcloud
from libcloud import _init_once
+from libcloud.base import DriverTypeNotFoundError
from libcloud.common.base import LoggingHTTPConnection
from libcloud.common.base import LoggingHTTPSConnection
@@ -61,5 +62,9 @@ class TestUtils(unittest.TestCase):
driver = libcloud.get_driver(libcloud.DriverType.COMPUTE, libcloud.DriverType.COMPUTE.EC2)
self.assertEqual(driver.__name__, 'EC2NodeDriver')
+ def test_raises_error(self):
+ with self.assertRaises(DriverTypeNotFoundError):
+ libcloud.get_driver('potato', 'potato')
+
if __name__ == '__main__':
sys.exit(unittest.main())