forked from weaselab/weaseljson
Merge pull request 'python: raise OSError when shared library is missing' (#44) from weaselbot/weaseljson:weaselbot/issue-38 into main
Reviewed-on: weaselab/weaseljson#44
This commit is contained in:
@@ -95,8 +95,20 @@ def test_create_rejects_too_small_stack():
|
|||||||
raise AssertionError(f"expected ValueError for stackSize={stack_size}")
|
raise AssertionError(f"expected ValueError for stackSize={stack_size}")
|
||||||
|
|
||||||
|
|
||||||
|
def test_missing_library_raises_oserror():
|
||||||
|
try:
|
||||||
|
weaseljson.WeaselJsonParser(
|
||||||
|
weaseljson.WeaselJsonCallbacksBase(),
|
||||||
|
build_dir="/nonexistent",
|
||||||
|
)
|
||||||
|
except OSError:
|
||||||
|
return
|
||||||
|
raise AssertionError("expected OSError when the shared library is missing")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
test_object_keys_routed_correctly()
|
test_object_keys_routed_correctly()
|
||||||
test_mixed_values()
|
test_mixed_values()
|
||||||
test_create_rejects_too_small_stack()
|
test_create_rejects_too_small_stack()
|
||||||
|
test_missing_library_raises_oserror()
|
||||||
print("python bindings ok")
|
print("python bindings ok")
|
||||||
|
|||||||
+1
-7
@@ -84,13 +84,7 @@ class WeaselJsonParser:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if self._lib is None:
|
if self._lib is None:
|
||||||
import sys
|
raise OSError(f"Could not load libweaseljson from {build_dir}")
|
||||||
|
|
||||||
print(
|
|
||||||
"Could not find libweaseljson implementation",
|
|
||||||
file=sys.stderr,
|
|
||||||
)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
self._lib.WeaselJsonParser_create.argtypes = (
|
self._lib.WeaselJsonParser_create.argtypes = (
|
||||||
ctypes.c_int,
|
ctypes.c_int,
|
||||||
|
|||||||
Reference in New Issue
Block a user