aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-06-17 17:37:39 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-06-19 18:56:37 +0900
commitbe86049aeb6b815e771c5863c712291b3604cf65 (patch)
treef6c83ed677ca06af84c80e0d8ebd455f74a8e8b2
parent6ccf88931b1dbf00b49a695ddb6bc765893f6874 (diff)
downloadlibhinoko-be86049aeb6b815e771c5863c712291b3604cf65.tar.gz
tests: add helper function to test enumerations and flags
This commit adds helper function for enumerations and flags. All of available enumerations and flags are available via object attributes. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--tests/helper.py9
-rw-r--r--tests/hinoko-enum10
2 files changed, 13 insertions, 6 deletions
diff --git a/tests/helper.py b/tests/helper.py
index bf5bc64..3a8e6fe 100644
--- a/tests/helper.py
+++ b/tests/helper.py
@@ -22,3 +22,12 @@ def test_object(target, props, methods, vmethods, signals) ->bool:
print('Signal {0} is not produced.'.format(signal))
return False
return True
+
+
+def test_enums(target_type: object, enumerations: tuple[str]) -> bool:
+ for enumeration in enumerations:
+ if not hasattr(target_type, enumeration):
+ print('Enumeration {0} is not produced for {1}.'.format(
+ enumeration, target_type))
+ return False
+ return True
diff --git a/tests/hinoko-enum b/tests/hinoko-enum
index 957fb69..ff1aa7e 100644
--- a/tests/hinoko-enum
+++ b/tests/hinoko-enum
@@ -3,7 +3,7 @@
from sys import exit
from errno import ENXIO
-from helper import test_object
+from helper import test_enums
import gi
gi.require_version('Hinoko', '0.0')
@@ -64,8 +64,6 @@ types = {
Hinoko.FwIsoCtxError: fw_iso_ctx_error_enumerations,
}
-for obj, types in types.items():
- for t in types:
- if not hasattr(obj, t):
- print('Enumerator {0} is not produced.'.format(t))
- exit(ENXIO)
+for target_type, enumerations in types.items():
+ if not test_enums(target_type, enumerations):
+ exit(ENXIO)