From dc25da1931d3fbebb64f35d37b1498f00d17141f Mon Sep 17 00:00:00 2001 From: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Date: Fri, 30 Jun 2023 02:52:42 -0700 Subject: tests/pythons: convert to new stand-alone test process (#38340) --- lib/spack/spack/build_systems/python.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/python.py b/lib/spack/spack/build_systems/python.py index f365fefe0f..7a355490f7 100644 --- a/lib/spack/spack/build_systems/python.py +++ b/lib/spack/spack/build_systems/python.py @@ -23,6 +23,7 @@ import spack.spec import spack.store from spack.directives import build_system, depends_on, extends, maintainers from spack.error import NoHeadersError, NoLibrariesError, SpecError +from spack.install_test import test_part from spack.version import Version from ._checks import BaseBuilder, execute_install_time_tests @@ -167,18 +168,20 @@ class PythonExtension(spack.package_base.PackageBase): view.remove_files(to_remove) - def test(self): + def test_imports(self): """Attempts to import modules of the installed package.""" # Make sure we are importing the installed modules, # not the ones in the source directory + python = inspect.getmodule(self).python.path for module in self.import_modules: - self.run_test( - inspect.getmodule(self).python.path, - ["-c", "import {0}".format(module)], - purpose="checking import of {0}".format(module), + with test_part( + self, + f"test_imports_{module}", + purpose=f"checking import of {module}", work_dir="spack-test", - ) + ): + python("-c", f"import {module}") def update_external_dependencies(self, extendee_spec=None): """ -- cgit v1.2.3-60-g2f50