Thumbnails: add None check on lib_name

`find_library` could return None, which would not cause an OSError
from `loadLibrary`, making the plugin (falsely) think the library is available

Also fixed  wrong method call to skip test in that case

See #1277
This commit is contained in:
Tom Jaspers 2015-03-30 19:56:22 +02:00
parent e953e6bdcb
commit c95b89ebc1
2 changed files with 3 additions and 1 deletions

View file

@ -241,6 +241,8 @@ class GioURI(URIGetter):
def get_library(self):
lib_name = ctypes.util.find_library("gio-2")
try:
if not lib_name:
return False
return ctypes.cdll.LoadLibrary(lib_name)
except OSError:
return False

View file

@ -265,7 +265,7 @@ class ThumbnailsTest(unittest.TestCase, TestHelper):
gio = GioURI()
plib = PathlibURI()
if not gio.available:
self.skip("GIO library not found")
self.skipTest("GIO library not found")
self.assertEqual(gio.uri("/foo"), b"file:///") # silent fail
self.assertEqual(gio.uri(b"/foo"), b"file:///foo")