summaryrefslogtreecommitdiffstats
path: root/bindings/test
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-10-21 21:50:46 +0200
committerDavid Robillard <d@drobilla.net>2019-10-21 21:50:46 +0200
commit7a7bff205975ac1668f71da1a7af172ead100849 (patch)
tree96e24e75ca904d744de2e1ef4f6a18cda560788c /bindings/test
parent06e30c3fc93a2cc59e8d0642e257f73b59c38974 (diff)
downloadlilv-7a7bff205975ac1668f71da1a7af172ead100849.tar.gz
lilv-7a7bff205975ac1668f71da1a7af172ead100849.tar.bz2
lilv-7a7bff205975ac1668f71da1a7af172ead100849.zip
Make Python bindings more Pythonic
Diffstat (limited to 'bindings/test')
-rw-r--r--bindings/test/python/test_api.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/bindings/test/python/test_api.py b/bindings/test/python/test_api.py
index c3e0752..59fc201 100644
--- a/bindings/test/python/test_api.py
+++ b/bindings/test/python/test_api.py
@@ -63,8 +63,8 @@ class UriTests(unittest.TestCase):
self.world.load_all()
def testInvalidURI(self):
- self.plugin_uri = self.world.new_uri("invalid_uri")
- self.assertIsNone(self.plugin_uri)
+ with self.assertRaises(ValueError):
+ self.plugin_uri = self.world.new_uri("invalid_uri")
def testNonExistentURI(self):
self.plugin_uri = self.world.new_uri("exist:does_not")
@@ -116,6 +116,8 @@ class PluginClassesTests(unittest.TestCase):
self.assertGreater(len(classes), 1)
self.assertIsNotNone(classes[0])
self.assertIsNotNone(classes[pclass.get_uri()])
+ with self.assertRaises(KeyError):
+ classes["http://example.org/notaclass"].get_uri()
class LoadTests(unittest.TestCase):
@@ -151,6 +153,9 @@ class PluginTests(unittest.TestCase):
self.assertTrue(self.plugin in self.plugins)
self.assertTrue(self.plugin.get_uri() in self.plugins)
self.assertEqual(self.plugins[self.plugin.get_uri()], self.plugin)
+ with self.assertRaises(KeyError):
+ self.plugins["http://example.org/notaplugin"].get_uri()
+
self.assertIsNotNone(
self.plugin,
msg="Test plugin not found at location: '" + location + "'",
@@ -386,6 +391,9 @@ class UITests(unittest.TestCase):
)
self.assertEqual(1, len(uis))
self.assertEqual(str(uis[0]), str(ui_uri))
+ with self.assertRaises(KeyError):
+ uis["http://example.org/notaui"].get_uri()
+
self.assertEqual(uis[0], str(ui_uri))
self.assertEqual(uis[0].get_uri(), ui_uri)
self.assertEqual(uis[0].get_bundle_uri(), self.bundle_uri)