diff options
author | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-03-20 14:12:06 +0000 |
---|---|---|
committer | Benjamin Schubert <ben.c.schubert@gmail.com> | 2019-03-21 16:40:43 +0000 |
commit | 9f6e8f9a933c4af6f250b54da014922dbe8d4584 (patch) | |
tree | 7da4fe157226a22714db4e6d90054ac5ace550df /tests/frontend | |
parent | aa326c937b0146269be78ff03a554d6c1d7826cb (diff) | |
download | buildstream-9f6e8f9a933c4af6f250b54da014922dbe8d4584.tar.gz |
tests: when comparing lists/dicts, compare all at once
This allows pytest to show a better report of the difference between
the two lists and not just tell that one entry is wrong.
Diffstat (limited to 'tests/frontend')
-rw-r--r-- | tests/frontend/artifact.py | 6 | ||||
-rw-r--r-- | tests/frontend/push.py | 14 | ||||
-rw-r--r-- | tests/frontend/track.py | 12 |
3 files changed, 22 insertions, 10 deletions
diff --git a/tests/frontend/artifact.py b/tests/frontend/artifact.py index eadc6d443..887649f96 100644 --- a/tests/frontend/artifact.py +++ b/tests/frontend/artifact.py @@ -128,8 +128,10 @@ def test_artifact_delete_element_and_artifact(cli, tmpdir, datafiles): # First build an element so that we can find its artifact result = cli.run(project=project, args=['build', element]) result.assert_success() - assert cli.get_element_state(project, element) == 'cached' - assert cli.get_element_state(project, dep) == 'cached' + assert cli.get_element_states(project, [element, dep], deps="none") == { + element: "cached", + dep: "cached", + } # Obtain the artifact ref cache_key = cli.get_element_key(project, element) diff --git a/tests/frontend/push.py b/tests/frontend/push.py index 919ce3a84..061607446 100644 --- a/tests/frontend/push.py +++ b/tests/frontend/push.py @@ -253,8 +253,12 @@ def test_artifact_expires(cli, datafiles, tmpdir): # check that element's 1 and 2 are cached both locally and remotely states = cli.get_element_states(project, ['element1.bst', 'element2.bst']) - assert states['element1.bst'] == 'cached' - assert states['element2.bst'] == 'cached' + + assert states == { + "element1.bst": "cached", + "element2.bst": "cached", + } + assert_shared(cli, share, project, 'element1.bst') assert_shared(cli, share, project, 'element2.bst') @@ -339,8 +343,10 @@ def test_recently_pulled_artifact_does_not_expire(cli, datafiles, tmpdir): # Ensure they are cached locally states = cli.get_element_states(project, ['element1.bst', 'element2.bst']) - assert states['element1.bst'] == 'cached' - assert states['element2.bst'] == 'cached' + assert states == { + "element1.bst": "cached", + "element2.bst": "cached", + } # Ensure that they have been pushed to the cache assert_shared(cli, share, project, 'element1.bst') diff --git a/tests/frontend/track.py b/tests/frontend/track.py index b3b063f69..5a6460d3d 100644 --- a/tests/frontend/track.py +++ b/tests/frontend/track.py @@ -51,8 +51,10 @@ def test_track_single(cli, tmpdir, datafiles): # Assert that tracking is needed for both elements states = cli.get_element_states(project, [element_target_name]) - assert states[element_dep_name] == 'no reference' - assert states[element_target_name] == 'no reference' + assert states == { + element_dep_name: "no reference", + element_target_name: "no reference", + } # Now first try to track only one element result = cli.run(project=project, args=[ @@ -68,8 +70,10 @@ def test_track_single(cli, tmpdir, datafiles): # Assert that the dependency is waiting and the target has still never been tracked states = cli.get_element_states(project, [element_target_name]) - assert states[element_dep_name] == 'no reference' - assert states[element_target_name] == 'waiting' + assert states == { + element_dep_name: 'no reference', + element_target_name: 'waiting', + } @pytest.mark.datafiles(os.path.join(TOP_DIR)) |