summaryrefslogtreecommitdiff
path: root/tests/sources/git.py
diff options
context:
space:
mode:
authorBenjamin Schubert <bschubert15@bloomberg.net>2019-12-02 11:34:31 +0000
committerBenjamin Schubert <bschubert15@bloomberg.net>2019-12-02 11:51:15 +0000
commite4ed02fbfcea355d6432e7a2e389af84a94120dd (patch)
tree6d42e69f8cd674a7be8041d1bcaf0f113762bb26 /tests/sources/git.py
parent1064374cf19ef5492c3b6b4a23ae14c49ac8ea86 (diff)
downloadbuildstream-e4ed02fbfcea355d6432e7a2e389af84a94120dd.tar.gz
tests: Use pytest.raise() instead of checking for return code
This gives a potentially more explicit understanding of what went wrong, and pytest can give better information about that exception than just us asserting the return code.
Diffstat (limited to 'tests/sources/git.py')
-rw-r--r--tests/sources/git.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/sources/git.py b/tests/sources/git.py
index fbb1394ec..e4252fe51 100644
--- a/tests/sources/git.py
+++ b/tests/sources/git.py
@@ -779,8 +779,8 @@ def test_git_describe(cli, tmpdir, datafiles, ref_storage, tag_type):
tags = set(tags.splitlines())
assert tags == set(["tag1", "tag2"])
- p = subprocess.run(["git", "log", repo.rev_parse("uselesstag")], cwd=checkout)
- assert p.returncode != 0
+ with pytest.raises(subprocess.CalledProcessError):
+ subprocess.run(["git", "log", repo.rev_parse("uselesstag")], cwd=checkout, check=True)
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")
@@ -888,8 +888,8 @@ def test_git_describe_head_is_tagged(cli, tmpdir, datafiles, ref_storage, tag_ty
assert set(rev_list.splitlines()) == set([tagged_ref])
- p = subprocess.run(["git", "log", repo.rev_parse("uselesstag")], cwd=checkout)
- assert p.returncode != 0
+ with pytest.raises(subprocess.CalledProcessError):
+ subprocess.run(["git", "log", repo.rev_parse("uselesstag")], cwd=checkout, check=True)
@pytest.mark.skipif(HAVE_GIT is False, reason="git is not available")