[Libguestfs] [PATCH 3/7] python: tests: catch specific exception

Pino Toscano ptoscano at redhat.com
Fri Jan 10 14:28:55 UTC 2020


When trying to import libvirt, catch the specific exception that is
raised when an importing fails.
---
 python/t/tests_helper.py.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/t/tests_helper.py.in b/python/t/tests_helper.py.in
index 93783430e..38f0dc521 100644
--- a/python/t/tests_helper.py.in
+++ b/python/t/tests_helper.py.in
@@ -56,7 +56,7 @@ def skipUnlessLibvirtHasCPointer():
     """
     try:
         import libvirt
-    except:
+    except ImportError:
         return unittest.skip("could not import libvirt")
     # Check we're using the version of libvirt-python that has
     # c_pointer() methods.
-- 
2.24.1




More information about the Libguestfs mailing list