diff options
-rw-r--r-- | src/buildstream/testing/_fixtures.py | 7 | ||||
-rw-r--r-- | src/buildstream/testing/_sourcetests/conftest.py | 2 | ||||
-rwxr-xr-x | tests/conftest.py | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/src/buildstream/testing/_fixtures.py b/src/buildstream/testing/_fixtures.py index 862cebe87..2684782a1 100644 --- a/src/buildstream/testing/_fixtures.py +++ b/src/buildstream/testing/_fixtures.py @@ -17,7 +17,7 @@ import psutil import pytest -from buildstream import utils +from buildstream import node, utils # Catch tests that don't shut down background threads, which could then lead # to other tests hanging when BuildStream uses fork(). @@ -29,3 +29,8 @@ def thread_check(): yield assert utils._is_single_threaded() + +# Reset global state in node.pyx to improve test isolation +@pytest.fixture(autouse=True) +def reset_global_node_state(): + node._reset_global_state() diff --git a/src/buildstream/testing/_sourcetests/conftest.py b/src/buildstream/testing/_sourcetests/conftest.py index f16c1e9ad..64dd404ef 100644 --- a/src/buildstream/testing/_sourcetests/conftest.py +++ b/src/buildstream/testing/_sourcetests/conftest.py @@ -14,4 +14,4 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library. If not, see <http://www.gnu.org/licenses/>. -from .._fixtures import thread_check # pylint: disable=unused-import +from .._fixtures import reset_global_node_state, thread_check # pylint: disable=unused-import diff --git a/tests/conftest.py b/tests/conftest.py index 0e39943d3..9189d263e 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,7 @@ import os import pytest from buildstream.testing import register_repo_kind, sourcetests_collection_hook -from buildstream.testing._fixtures import thread_check # pylint: disable=unused-import +from buildstream.testing._fixtures import reset_global_node_state, thread_check # pylint: disable=unused-import from buildstream.testing._forked import forked_run_report from buildstream.testing.integration import integration_cache # pylint: disable=unused-import |