Skip to content

Commit ae8e6f0

Browse files
committed
Add test for pyscript global variable casting
Test for #420
1 parent 8ce4e0e commit ae8e6f0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -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

+15
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,20 @@ public void TestSysArgsImportException()
6464
PyObject module = PythonEngine.ImportModule("PyImportTest.sysargv");
6565
Assert.IsNotNull(module);
6666
}
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+
}
6782
}
6883
}

0 commit comments

Comments
 (0)