Skip to content

Commit 913e429

Browse files
committed
allow tests to pass when objects are leaking due to being GCed after Python runtime is shut down
1 parent 5193deb commit 913e429

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/embed_tests/GlobalTestsSetup.cs

+16
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)