aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/python_annotations_variable_c_runme.py
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/python/python_annotations_variable_c_runme.py')
-rw-r--r--Examples/test-suite/python/python_annotations_variable_c_runme.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Examples/test-suite/python/python_annotations_variable_c_runme.py b/Examples/test-suite/python/python_annotations_variable_c_runme.py
new file mode 100644
index 000000000..153852d05
--- /dev/null
+++ b/Examples/test-suite/python/python_annotations_variable_c_runme.py
@@ -0,0 +1,24 @@
+import sys
+
+# Variable annotations for properties is only supported in python-3.6 and later (PEP 526)
+if sys.version_info[0:2] >= (3, 6):
+ from python_annotations_variable_c import *
+
+ # No SWIG __annotations__ support with -builtin or -fastproxy
+ annotations_supported = not(is_python_builtin() or is_python_fastproxy())
+
+ if annotations_supported:
+ ts = TemplateShort()
+ anno = ts.__annotations__
+ if anno != {'member_variable': 'int'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ ts = StructWithVar()
+ anno = ts.__annotations__
+ if anno != {'member_variable': 'int'}:
+ raise RuntimeError("annotations mismatch: {}".format(anno))
+
+ ts = StructWithVarNotAnnotated()
+ if getattr(ts, "__annotations__", None) != None:
+ anno = ts.__annotations__
+ raise RuntimeError("annotations mismatch: {}".format(anno))