diff --git a/lib/spack/spack/test/repo.py b/lib/spack/spack/test/repo.py index cb9f12fc79b..33f95f0c345 100644 --- a/lib/spack/spack/test/repo.py +++ b/lib/spack/spack/test/repo.py @@ -247,9 +247,10 @@ def test_real_name(self, module_name, pkg_name, mock_test_cache, tmp_path): used to import the Python module. """ path, _ = spack.repo.create_repo(str(tmp_path), package_api=(1, 0)) - pkg_path = pathlib.Path(path) / "packages" / pkg_name / "package.py" - pkg_path.parent.mkdir(parents=True) - pkg_path.write_text("") + if pkg_name is not None: + pkg_path = pathlib.Path(path) / "packages" / pkg_name / "package.py" + pkg_path.parent.mkdir(parents=True) + pkg_path.write_text("") repo = spack.repo.Repo( path, cache=spack.util.file_cache.FileCache(str(tmp_path / "cache")) )