summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-09-03 19:43:21 +0200
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-04 09:42:20 +0000
commitfa974ab31ea361981b68c3b98ff81f448535cce9 (patch)
tree5e165bdd00092281f29cfa3d7c1daf990f33a81e
parenta9364a40620e2ad2c299cdccee3d7da39fdd25b5 (diff)
downloadbuildstream-juerg/synthetic-file-index.tar.gz
tests: Add autouse fixture to reset global state in node.pyxjuerg/synthetic-file-index
-rw-r--r--src/buildstream/testing/_fixtures.py7
-rw-r--r--src/buildstream/testing/_sourcetests/conftest.py2
-rwxr-xr-xtests/conftest.py2
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