summaryrefslogtreecommitdiff
path: root/tests/internals
diff options
context:
space:
mode:
authorTristan Maat <tristan.maat@codethink.co.uk>2019-09-18 17:55:19 +0100
committerTristan Maat <tristan.maat@codethink.co.uk>2019-10-10 12:21:15 +0100
commit17144d84c2b63daf6e3aa9b42c6c773f134e8660 (patch)
tree1fd9a4e53ed641592dd26e3d07d241554463a4cf /tests/internals
parentacf99b789a92e9e124e9492d1dbbc34b83f5ab23 (diff)
downloadbuildstream-17144d84c2b63daf6e3aa9b42c6c773f134e8660.tar.gz
testutils/context.py: Mock tasks instead of accepting Nones
To ensure that we only disable element loading task progress reporting for very specific code paths, we need to teach the test suite to be a bit smarter. For this reason we now mock a _Task object and return it in our mock context's relevant method invocations. Other code paths that deliberately invoke the loader without task reporting now mark their loads with NO_PROGRESS.
Diffstat (limited to 'tests/internals')
-rw-r--r--tests/internals/loader.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/internals/loader.py b/tests/internals/loader.py
index 9af2bf161..39ef8ac99 100644
--- a/tests/internals/loader.py
+++ b/tests/internals/loader.py
@@ -5,6 +5,7 @@ import pytest
from buildstream._exceptions import LoadError, LoadErrorReason
from buildstream._project import Project
from buildstream._loader import MetaElement
+from buildstream._loader.loader import _NO_PROGRESS
from tests.testutils import dummy_context
@@ -30,7 +31,7 @@ def test_one_file(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader:
- element = loader.load(['elements/onefile.bst'])[0]
+ element = loader.load(['elements/onefile.bst'], _NO_PROGRESS)[0]
assert isinstance(element, MetaElement)
assert element.kind == 'pony'
@@ -41,7 +42,7 @@ def test_missing_file(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load(['elements/missing.bst'])
+ loader.load(['elements/missing.bst'], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.MISSING_FILE
@@ -51,7 +52,7 @@ def test_invalid_reference(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load(['elements/badreference.bst'])
+ loader.load(['elements/badreference.bst'], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.INVALID_YAML
@@ -61,7 +62,7 @@ def test_invalid_yaml(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load(['elements/badfile.bst'])
+ loader.load(['elements/badfile.bst'], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.INVALID_YAML
@@ -73,7 +74,7 @@ def test_fail_fullpath_target(datafiles):
fullpath = os.path.join(basedir, 'elements', 'onefile.bst')
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load([fullpath])
+ loader.load([fullpath], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.INVALID_DATA
@@ -83,7 +84,7 @@ def test_invalid_key(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load(['elements/invalidkey.bst'])
+ loader.load(['elements/invalidkey.bst'], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.INVALID_DATA
@@ -93,6 +94,6 @@ def test_invalid_directory_load(datafiles):
basedir = str(datafiles)
with make_loader(basedir) as loader, pytest.raises(LoadError) as exc:
- loader.load(['elements/'])
+ loader.load(['elements/'], _NO_PROGRESS)
assert exc.value.reason == LoadErrorReason.LOADING_DIRECTORY