From e4ed02fbfcea355d6432e7a2e389af84a94120dd Mon Sep 17 00:00:00 2001 From: Benjamin Schubert Date: Mon, 2 Dec 2019 11:34:31 +0000 Subject: 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. --- tests/sources/git.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/sources/git.py') 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") -- cgit v1.2.1