Skip to content
Snippets Groups Projects
Commit 81ea9688 authored by Benjamin Schubert's avatar Benjamin Schubert
Browse files

Ensure platform is not maintained between tests

This removes the `_instance` on the platform object that we use
for caching and not recreating the object everytime at the start
of every test.

This is to ensure our tests share the least amount of state.

The performance penalty is from 2 to 5% accross the whole test suite.
The readings were done 5 times for each before and after the change
and on the same computer.
parent 8931e42c
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,8 @@ import shutil ...@@ -23,6 +23,8 @@ import shutil
import pytest import pytest
from buildstream._platform.platform import Platform
def pytest_addoption(parser): def pytest_addoption(parser):
parser.addoption('--integration', action='store_true', default=False, parser.addoption('--integration', action='store_true', default=False,
...@@ -52,3 +54,8 @@ def integration_cache(request): ...@@ -52,3 +54,8 @@ def integration_cache(request):
shutil.rmtree(os.path.join(cache_dir, 'artifacts')) shutil.rmtree(os.path.join(cache_dir, 'artifacts'))
except FileNotFoundError: except FileNotFoundError:
pass pass
@pytest.fixture(autouse=True)
def clean_platform_cache():
Platform._instance = None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment