diff --git a/tests.py b/tests.py index be7c6b288ba46eee74b08e285e281e79994de51f..d68cc4e38a6bb00614f7f22d826c74f516365841 100644 --- a/tests.py +++ b/tests.py @@ -1,3 +1,5 @@ +"""Tests for mpsd-software-environment.py.""" + import importlib import os import shutil @@ -10,7 +12,7 @@ mod = importlib.import_module("mpsd-software-environment") def test_os_chdir(tmp_path): - # create a temporary directory for testing + """Create a temporary directory for testing.""" temp_dir = tmp_path / "test_os_chdir" temp_dir.mkdir() @@ -26,11 +28,13 @@ def test_os_chdir(tmp_path): def test_prepare_environment(tmp_path): - # simulate running ./install-software-environment.py --release dev-23a \ - # --target-directory /tmp/test_prepare_env - # prepare_env is run when cmd is not specified, we can test cmd='prepare' - # and cmd=None to check both cases + """Simulate running preparation of environment. + Simulate running ./install-software-environment.py --release dev-23a \ + --target-directory /tmp/test_prepare_env + prepare_env is run when cmd is not specified, we can test cmd='prepare' + and cmd=None to check both cases + """ script_dir = tmp_path / "test_prepare_env" spack_environments = "spack-environments" mpsd_release_to_test = "dev-23a" @@ -71,7 +75,10 @@ def test_prepare_environment(tmp_path): def test_setup_log_cmd(tmp_path): - # check that logs/install-software-environment.log is updated when the module is run + """Check that log is updated. + + Check that logs/install-software-environment.log is updated when the module is run + """ log_file = "install.log" script_dir = tmp_path / "test_prepare_env" @@ -96,11 +103,13 @@ def test_setup_log_cmd(tmp_path): def test_install_environment(tmp_path): - # Test the installation part - # This is a long test, its handy to test this with print statements printed to - # stdout, use: - # pytest -s - # Expect an Exception when wrong toolchains are provided + """Test the installation of a toolchain. + + This is a long test, its handy to test this with print statements printed to + stdout, use: + pytest -s + Expect an Exception when wrong toolchains are provided + """ with pytest.raises(Exception): mod.install_environment( mpsd_release="dev-23a", @@ -213,6 +222,7 @@ def test_install_environment(tmp_path): def test_interface(tmp_path): + """Test other things (not implemented yet).""" pass # ensure that installing without toolchains only passes the available toolchains # check that the script branch and hash are correct when running the script