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

Skip to content

Commit cee43bd

Browse files
committed
allow tests to pass when objects are leaking due to being GCed after Python runtime is shut down
1 parent 2ab6ec2 commit cee43bd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/embed_tests/GlobalTestsSetup.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ namespace Python.EmbeddingTest
99
[SetUpFixture]
1010
public partial class GlobalTestsSetup
1111
{
12+
[OneTimeSetUp]
13+
public void GlobalSetup()
14+
{
15+
Finalizer.Instance.ErrorHandler += FinalizerErrorHandler;
16+
}
17+
18+
private void FinalizerErrorHandler(object sender, Finalizer.ErrorArgs e)
19+
{
20+
if (e.Error is RuntimeShutdownException)
21+
{
22+
// allow objects to leak after the python runtime run
23+
// they were created in is gone
24+
e.Handled = true;
25+
}
26+
}
27+
1228
[OneTimeTearDown]
1329
public void FinalCleanup()
1430
{

0 commit comments

Comments
 (0)