Skip to content
Merged
Prev Previous commit
Next Next commit
allow tests to pass when objects are leaking due to being GCed after …
…Python runtime is shut down
  • Loading branch information
lostmsu committed Nov 12, 2021
commit 3909639ce1b0c17b66707208592a0d7c991645b6
16 changes: 16 additions & 0 deletions src/embed_tests/GlobalTestsSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ namespace Python.EmbeddingTest
[SetUpFixture]
public partial class GlobalTestsSetup
{
[OneTimeSetUp]
public void GlobalSetup()
{
Finalizer.Instance.ErrorHandler += FinalizerErrorHandler;
}

private void FinalizerErrorHandler(object sender, Finalizer.ErrorArgs e)
{
if (e.Error is RuntimeShutdownException)
{
// allow objects to leak after the python runtime run
// they were created in is gone
e.Handled = true;
}
}

[OneTimeTearDown]
public void FinalCleanup()
{
Expand Down