Skip to content
Merged
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
Next Next commit
Bug: Py_Initialize/Py_Finalize calls during alive PythonEngine. Fixed.
  • Loading branch information
dse authored and filmor committed Nov 14, 2018
commit ccd60034d6b7c065b49d9a4ad68d9eda96e97150
16 changes: 13 additions & 3 deletions src/embed_tests/TestRuntime.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
using System;
using System;
using NUnit.Framework;
using Python.Runtime;

namespace Python.EmbeddingTest
{
public class TestRuntime
{
[OneTimeSetUp]
public void SetUp()
{
// We needs to ensure that no any engines are running.
if (PythonEngine.IsInitialized)
{
PythonEngine.Shutdown();
}
}

/// <summary>
/// Test the cache of the information from the platform module.
///
Expand All @@ -24,12 +34,12 @@ public static void PlatformCache()

// Don't shut down the runtime: if the python engine was initialized
// but not shut down by another test, we'd end up in a bad state.
}
}

[Test]
public static void Py_IsInitializedValue()
{
Runtime.Runtime.Py_Finalize(); // In case another test left it on.
Runtime.Runtime.Py_Finalize();
Assert.AreEqual(0, Runtime.Runtime.Py_IsInitialized());
Runtime.Runtime.Py_Initialize();
Assert.AreEqual(1, Runtime.Runtime.Py_IsInitialized());
Expand Down