From 55d4bbbbd83323fcc1133b4c4fb0be543c43d85a Mon Sep 17 00:00:00 2001 From: Victor Uriarte Date: Tue, 21 Feb 2017 09:10:18 -0700 Subject: [PATCH] Enable embedded_tests to Travis w. conditional filters Add conditional class skip to pytuple for Travis/PY27 Add individual filters to other tests as needed https://www.amido.com/code/conditional-ignore-nunit-and-the-ability-to-conditionally-ignore-a-test/ http://stackoverflow.com/a/16075029/5208670 --- .travis.yml | 2 +- src/embed_tests/dynamic.cs | 17 ++++++++++++++++- src/embed_tests/pyinitialize.cs | 5 +++++ src/embed_tests/pytuple.cs | 28 ++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd3b9fdf7..95e13b574 100644 --- a/.travis.yml +++ b/.travis.yml @@ -42,7 +42,7 @@ script: - python -m pytest - cp Python.Runtime.dll.config src/embed_tests/bin/ - # - mono ./packages/NUnit.*/tools/nunit3-console.exe src/embed_tests/bin/Python.EmbeddingTest.dll + - mono ./packages/NUnit.*/tools/nunit3-console.exe src/embed_tests/bin/Python.EmbeddingTest.dll after_script: # Uncomment if need to geninterop, ie. py37 final diff --git a/src/embed_tests/dynamic.cs b/src/embed_tests/dynamic.cs index 8338d68f6..4130323fd 100644 --- a/src/embed_tests/dynamic.cs +++ b/src/embed_tests/dynamic.cs @@ -58,13 +58,25 @@ public void AssignNone() /// Check whether we can get the attr of a python object when the /// value of attr is a PyObject. /// + /// + /// FIXME: Issue on Travis PY27: Error : Python.EmbeddingTest.dynamicTest.AssignPyObject + /// Python.Runtime.PythonException : ImportError : /home/travis/virtualenv/python2.7.9/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyLong_AsInt + /// [Test] public void AssignPyObject() { + if (Environment.GetEnvironmentVariable("TRAVIS") == "true" && + Environment.GetEnvironmentVariable("TRAVIS_PYTHON_VERSION") == "2.7") + { + // Most recently threw `auto-releasing thread-state, but no thread-state for this thread` + // instead of the error below. Maybe had bad mapping to library? + Assert.Ignore("Fails on Travis/PY27: ImportError: ... undefined symbol: _PyLong_AsInt"); + } + dynamic sys = Py.Import("sys"); dynamic io = Py.Import("io"); sys.testattr = io.StringIO(); - dynamic bb = sys.testattr; //Get the PyObject + dynamic bb = sys.testattr; // Get the PyObject bb.write("Hello!"); Assert.AreEqual(bb.getvalue().ToString(), "Hello!"); } @@ -72,6 +84,9 @@ public void AssignPyObject() /// /// Pass the .NET object in Python side. /// + /// + /// FIXME: Possible source of intermittent Travis PY27: Unable to unload AppDomain. + /// [Test] public void PassObjectInPython() { diff --git a/src/embed_tests/pyinitialize.cs b/src/embed_tests/pyinitialize.cs index 2f9aae2c7..2bfbd1a41 100644 --- a/src/embed_tests/pyinitialize.cs +++ b/src/embed_tests/pyinitialize.cs @@ -33,6 +33,11 @@ public static void LoadDefaultArgs() [Test] public static void LoadSpecificArgs() { + if (Environment.GetEnvironmentVariable("TRAVIS") == "true" && + Environment.GetEnvironmentVariable("TRAVIS_PYTHON_VERSION") != "2.7") + { + Assert.Ignore("FIXME: Fails on Travis/PY3+: Fatal Python error: no mem for sys.argv"); + } var args = new[] { "test1", "test2" }; using (new PythonEngine(args)) using (var argv = new PyList(Runtime.Runtime.PySys_GetObject("argv"))) diff --git a/src/embed_tests/pytuple.cs b/src/embed_tests/pytuple.cs index ef72d2ea9..88910147c 100644 --- a/src/embed_tests/pytuple.cs +++ b/src/embed_tests/pytuple.cs @@ -6,10 +6,37 @@ namespace Python.EmbeddingTest { public class PyTupleTest { + /// + /// Tests set-up. Being used to skip class on Travis/PY27 + /// + /// + /// FIXME: Fails on Travis/PY27: All tests below (unless otherwise stated) + /// Fatal Python error: auto-releasing thread-state, but no thread-state for this thread + /// Stacktrace: + /// at (wrapper managed-to-native) Python.Runtime.Runtime.PyGILState_Release (intptr) + /// at Python.Runtime.PythonEngine.ReleaseLock (intptr) + /// at Python.Runtime.PythonException.Dispose () + /// at Python.Runtime.PythonException.Finalize () + /// at (wrapper runtime-invoke) object.runtime_invoke_virtual_void__this__ (object,intptr,intptr,intptr) + /// + [SetUp] + public void SetUp() + { + if (Environment.GetEnvironmentVariable("TRAVIS") == "true" && + Environment.GetEnvironmentVariable("TRAVIS_PYTHON_VERSION") == "2.7") + { + Assert.Ignore("Fails on Travis/PY27: Fatal Python error: auto-releasing thread-state, but no thread-state for this thread"); + } + } + /// /// Test IsTupleType without having to Initialize a tuple. /// PyTuple constructor use IsTupleType. This decouples the tests. /// + /// + /// Travis PY27 intermittently fails this test. Indicates issue is + /// most likely with PyTuple.IsTupleType + /// [Test] public void TestStringIsTupleType() { @@ -104,6 +131,7 @@ public void TestPyTupleValidConvert() /// /// FIXME: Possible source of intermittent AppVeyor PY27: Unable to unload AppDomain. + /// FIXME: Intermittent Issue on Travis PY33: Fatal Python error: PyMUTEX_LOCK(gil_mutex) failed. Seen twice. /// [Test] public void TestNewPyTupleFromPyTuple()