Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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
  • Loading branch information
vmuriart committed Feb 23, 2017
commit 2dfff9f21601afe742477fda4c3df1040925c91a
12 changes: 6 additions & 6 deletions src/embed_tests/pyrunstring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public void Dispose()
public void TestRunSimpleString()
{
int aa = PythonEngine.RunSimpleString("import sys");
Assert.AreEqual(aa, 0);
Assert.AreEqual(0, aa);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yagweb I think you had these backwards by mistake, its the opposite other than python. I fixed them before merge.


int bb = PythonEngine.RunSimpleString("import 1234");
Assert.AreEqual(bb, -1);
Assert.AreEqual(-1, bb);
}

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

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

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

PythonEngine.Exec("c = sys.attr1 + a + 1", null, locals.Handle);
object c = locals.GetItem("c").AsManagedObject(typeof(Int32));
Assert.AreEqual(c, 111);
object c = locals.GetItem("c").AsManagedObject(typeof(int));
Assert.AreEqual(111, c);
}
}
}
2 changes: 1 addition & 1 deletion src/runtime/pythonengine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public static void Exec(string code, IntPtr? globals = null, IntPtr? locals = nu
/// executing the code string as a PyObject instance, or null if
/// an exception was raised.
/// </remarks>
internal static PyObject RunString(
public static PyObject RunString(
string code, IntPtr? globals = null, IntPtr? locals = null, RunFlagType _flag = RunFlagType.File
)
{
Expand Down