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

Skip to content

Commit 04ce393

Browse files
committed
Merge branch 'embedded_tests' into pythonnet_master
2 parents c0fb3f2 + e75d1c2 commit 04ce393

File tree

2 files changed

+62
-27
lines changed

2 files changed

+62
-27
lines changed

src/embed_tests/pyinitialize.cs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ namespace Python.EmbeddingTest
55
{
66
public class PyInitializeTest
77
{
8+
/// <summary>
9+
/// Tests issue with multiple simple Initialize/Shutdowns.
10+
/// Fixed by #343
11+
/// </summary>
812
[Test]
9-
public static void LoadSpecificArgs()
13+
public static void StartAndStopTwice()
1014
{
11-
var args = new[] { "test1", "test2" };
12-
using (new PythonEngine(args))
13-
using (var argv = new PyList(Runtime.Runtime.PySys_GetObject("argv")))
14-
{
15-
Assert.AreEqual(args[0], argv[0].ToString());
16-
Assert.AreEqual(args[1], argv[1].ToString());
17-
}
15+
PythonEngine.Initialize();
16+
PythonEngine.Shutdown();
17+
18+
PythonEngine.Initialize();
19+
PythonEngine.Shutdown();
1820
}
1921

2022
[Test]
@@ -28,17 +30,24 @@ public static void LoadDefaultArgs()
2830
}
2931

3032
[Test]
31-
public static void StartAndStopTwice()
33+
public static void LoadSpecificArgs()
3234
{
33-
PythonEngine.Initialize();
34-
PythonEngine.Shutdown();
35-
36-
PythonEngine.Initialize();
37-
PythonEngine.Shutdown();
35+
var args = new[] { "test1", "test2" };
36+
using (new PythonEngine(args))
37+
using (var argv = new PyList(Runtime.Runtime.PySys_GetObject("argv")))
38+
{
39+
Assert.AreEqual(args[0], argv[0].ToString());
40+
Assert.AreEqual(args[1], argv[1].ToString());
41+
}
3842
}
3943

44+
/// <summary>
45+
/// Failing test demonstrating current issue with OverflowException (#376)
46+
/// and ArgumentException issue after that one is fixed.
47+
/// More complex version of StartAndStopTwice test
48+
/// </summary>
4049
[Test]
41-
[Ignore("System.OverflowException : Arithmetic operation resulted in an overflow")]
50+
[Ignore("GH#376: System.OverflowException : Arithmetic operation resulted in an overflow")]
4251
//[Ignore("System.ArgumentException : Cannot pass a GCHandle across AppDomains")]
4352
public void ReInitialize()
4453
{

src/embed_tests/pytuple.cs

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@ namespace Python.EmbeddingTest
55
{
66
public class PyTupleTest
77
{
8+
/// <summary>
9+
/// Test IsTupleType without having to Initialize a tuple.
10+
/// PyTuple constructor use IsTupleType. This decouples the tests.
11+
/// </summary>
12+
[Test]
13+
public void TestStringIsTupleType()
14+
{
15+
using (Py.GIL())
16+
{
17+
var s = new PyString("foo");
18+
Assert.IsFalse(PyTuple.IsTupleType(s));
19+
}
20+
}
21+
22+
/// <summary>
23+
/// Test IsTupleType with Tuple.
24+
/// </summary>
25+
[Test]
26+
public void TestPyTupleIsTupleType()
27+
{
28+
using (Py.GIL())
29+
{
30+
var t = new PyTuple();
31+
Assert.IsTrue(PyTuple.IsTupleType(t));
32+
}
33+
}
34+
835
[Test]
936
public void TestPyTupleEmpty()
1037
{
@@ -15,7 +42,15 @@ public void TestPyTupleEmpty()
1542
}
1643
}
1744

45+
/// <remarks>
46+
/// FIXME: Unable to unload AppDomain, Unload thread timed out.
47+
/// Seen on Travis/AppVeyor on both PY2 and PY3. Causes Embedded_Tests
48+
/// to hang after they are finished for ~40 seconds until nunit3 forces
49+
/// a timeout on unloading tests. Doesn't fail the tests though but
50+
/// greatly slows down CI. nunit2 silently has this issue.
51+
/// </remarks>
1852
[Test]
53+
[Ignore("GH#397: Travis/AppVeyor: Unable to unload AppDomain, Unload thread timed out")]
1954
public void TestPyTupleInvalidAppend()
2055
{
2156
using (Py.GIL())
@@ -39,18 +74,6 @@ public void TestPyTupleValidAppend()
3974
}
4075
}
4176

42-
[Test]
43-
public void TestPyTupleIsTupleType()
44-
{
45-
using (Py.GIL())
46-
{
47-
var s = new PyString("foo");
48-
var t = new PyTuple();
49-
Assert.IsTrue(PyTuple.IsTupleType(t));
50-
Assert.IsFalse(PyTuple.IsTupleType(s));
51-
}
52-
}
53-
5477
[Test]
5578
public void TestPyTupleStringConvert()
5679
{
@@ -78,6 +101,9 @@ public void TestPyTupleValidConvert()
78101
}
79102
}
80103

104+
/// <remarks>
105+
/// FIXME: Possible source of intermittent AppVeyor PY27: Unable to unload AppDomain.
106+
/// </remarks>
81107
[Test]
82108
public void TestNewPyTupleFromPyTuple()
83109
{

0 commit comments

Comments
 (0)