Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bcadc48

Browse files
committed
Keep RunString Public. Fix Assert.AreEqual order
- Deprecation/Removal should be a separate issue/pr - In NUnit/XUnit, expected is the first argument, actual is second. Opposite to how Python does it
1 parent ea44eef commit bcadc48

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/embed_tests/pyrunstring.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using NUnit.Framework;
33
using Python.Runtime;
44

@@ -24,10 +24,10 @@ public void Dispose()
2424
public void TestRunSimpleString()
2525
{
2626
int aa = PythonEngine.RunSimpleString("import sys");
27-
Assert.AreEqual(aa, 0);
27+
Assert.AreEqual(0, aa);
2828

2929
int bb = PythonEngine.RunSimpleString("import 1234");
30-
Assert.AreEqual(bb, -1);
30+
Assert.AreEqual(-1, bb);
3131
}
3232

3333
[Test]
@@ -40,8 +40,8 @@ public void TestEval()
4040
locals.SetItem("a", new PyInt(10));
4141

4242
object b = PythonEngine.Eval("sys.attr1 + a + 1", null, locals.Handle)
43-
.AsManagedObject(typeof(Int32));
44-
Assert.AreEqual(b, 111);
43+
.AsManagedObject(typeof(int));
44+
Assert.AreEqual(111, b);
4545
}
4646

4747
[Test]
@@ -54,8 +54,8 @@ public void TestExec()
5454
locals.SetItem("a", new PyInt(10));
5555

5656
PythonEngine.Exec("c = sys.attr1 + a + 1", null, locals.Handle);
57-
object c = locals.GetItem("c").AsManagedObject(typeof(Int32));
58-
Assert.AreEqual(c, 111);
57+
object c = locals.GetItem("c").AsManagedObject(typeof(int));
58+
Assert.AreEqual(111, c);
5959
}
6060
}
6161
}

src/runtime/pythonengine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public static void Exec(string code, IntPtr? globals = null, IntPtr? locals = nu
432432
/// executing the code string as a PyObject instance, or null if
433433
/// an exception was raised.
434434
/// </remarks>
435-
internal static PyObject RunString(
435+
public static PyObject RunString(
436436
string code, IntPtr? globals = null, IntPtr? locals = null, RunFlagType _flag = RunFlagType.File
437437
)
438438
{

0 commit comments

Comments
 (0)