From 5594bf31ea463e0217562c4ef344e2611de74cb6 Mon Sep 17 00:00:00 2001 From: Hans Fangohr <hans.fangohr@mpsd.mpg.de> Date: Tue, 30 May 2023 20:47:42 +0200 Subject: [PATCH] improvements to test - check that "* dev23a" is somewhere in the string (not required to be in the first line) - create local variables before we run the assert statement. The can be inspected when calling `py.test -l` (or `py.test --pdb`). - improve documentation of what we expect --- tests.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests.py b/tests.py index fd4e0b9..c16d60b 100644 --- a/tests.py +++ b/tests.py @@ -94,17 +94,19 @@ def test_prepare_environment(tmp_path): assert release_base_dir.exists() # check for spack-environments directory assert spack_environments in os.listdir(release_base_dir) - # check if the git branch is correctly checked out - assert ( + + # check if the git branch is correctly checked out. We expect output such as + # git_branch_stdout = '* dev-23a\n develop\n' + # The entry with the '* ' prefix is the active branch. + git_branch_output_raw = \ subprocess.run( f"cd {str(release_base_dir/spack_environments)} && git branch", shell=True, capture_output=True, ) - .stdout.decode("utf-8") - .split("\n")[0] - == f"* {mpsd_release_to_test}" - ) + git_branch_stdout = git_branch_output_raw.stdout.decode("utf-8") + assert f"* {mpsd_release_to_test}" in git_branch_stdout + # check that result is a list and contains atleast ['global','foss2021a-mpi'] assert isinstance(result, list) assert "global" in result -- GitLab