Skip to content

Commit 269c479

Browse files
committed
chore: apply pytest teardown function globally to all test functions in all files in tests/python/ directory
1 parent 8fca917 commit 269c479

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

tests/python/conftest.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import pytest
2+
import pythonmonkey as pm
3+
import gc
4+
5+
# This is run at the end of each test function
6+
@pytest.fixture(scope="function", autouse=True)
7+
def teardown_function():
8+
"""
9+
Forcing garbage collection (twice) whenever a test function finishes,
10+
to locate GC-related errors
11+
"""
12+
gc.collect(), pm.collect()
13+
gc.collect(), pm.collect()

tests/python/test_pythonmonkey_eval.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
import asyncio
88
import numpy, array, struct
99

10-
# https://doc.pytest.org/en/latest/how-to/xunit_setup.html#method-and-function-level-setup-teardown
11-
def teardown_function(function):
12-
"""
13-
Forcing garbage collection (twice) whenever a test function finishes,
14-
to locate GC-related errors
15-
"""
16-
gc.collect(), pm.collect()
17-
gc.collect(), pm.collect()
18-
1910
def test_passes():
2011
assert True
2112

0 commit comments

Comments
 (0)