We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ce4e0e commit ae8e6f0Copy full SHA for ae8e6f0
src/embed_tests/fixtures/PyImportTest/cast_global_var.py
@@ -0,0 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+FOO = 1
4
5
6
+def test_foo():
7
+ return FOO
src/embed_tests/pyimport.cs
@@ -64,5 +64,20 @@ public void TestSysArgsImportException()
64
PyObject module = PythonEngine.ImportModule("PyImportTest.sysargv");
65
Assert.IsNotNull(module);
66
}
67
68
+ /// <summary>
69
+ /// Test Global Variable casting. GH#420
70
+ /// </summary>
71
+ [Test]
72
+ public void TestCastGlobalVar()
73
+ {
74
+ dynamic foo = Py.Import("PyImportTest.cast_global_var");
75
+ Assert.AreEqual("1", foo.FOO.ToString());
76
+ Assert.AreEqual("1", foo.test_foo().ToString());
77
78
+ foo.FOO = 2;
79
+ Assert.AreEqual("2", foo.FOO.ToString());
80
+ Assert.AreEqual("2", foo.test_foo().ToString());
81
+ }
82
83
0 commit comments