aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/python_annotations_c_runme.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/python/python_annotations_c_runme.py')
-rw-r--r--Examples/test-suite/python/python_annotations_c_runme.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Examples/test-suite/python/python_annotations_c_runme.py b/Examples/test-suite/python/python_annotations_c_runme.py
new file mode 100644
index 000000000..3110d8f83
--- /dev/null
+++ b/Examples/test-suite/python/python_annotations_c_runme.py
@@ -0,0 +1,31 @@
+import sys
+
+if sys.version_info[0:2] >= (3, 2):
+ from python_annotations_c import *
+
+ # No __annotations__ support with -builtin or -fastproxy
+ annotations_supported = not(is_python_builtin() or is_python_fastproxy())
+
+ if annotations_supported:
+ anno = MakeShort.__annotations__
+ if anno != {'x': 'int', 'return': 'Space::Template< short >'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ anno = global_ints.__annotations__
+ if anno != {'ri': 'int &', 't': 'TemplateShort', 'return': 'int *'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ ts = MakeShort(10)
+
+ anno = MakeShort.__annotations__
+ if anno != {'x': 'int', 'return': 'Space::Template< short >'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ anno = ts.mymethod.__annotations__
+ if anno != {'arg2': 'int', 'tt': 'TemplateShort', 'return': 'void'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ # No annotations
+ anno = no_annotations.__annotations__
+ if anno != {}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))