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) --- var/spack/repos/builtin/packages/python/package.py | 25 +++++++++++----------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/python/package.py b/var/spack/repos/builtin/packages/python/package.py index f2c9c5945e..7029a7f99d 100644 --- a/var/spack/repos/builtin/packages/python/package.py +++ b/var/spack/repos/builtin/packages/python/package.py @@ -1195,19 +1195,18 @@ print(json.dumps(config)) else: os.remove(dst) - def test(self): + def test_hello_world(self): + """run simple hello world program""" # do not use self.command because we are also testing the run env - exe = self.spec["python"].command.name + python = self.spec["python"].command - # test hello world msg = "hello world!" - reason = "test: running {0}".format(msg) - options = ["-c", 'print("{0}")'.format(msg)] - self.run_test(exe, options=options, expected=[msg], installed=True, purpose=reason) - - # checks import works and executable comes from the spec prefix - reason = "test: checking import and executable" - options = ["-c", "import sys; print(sys.executable)"] - self.run_test( - exe, options=options, expected=[self.spec.prefix], installed=True, purpose=reason - ) + out = python("-c", f'print("{msg}")', output=str.split, error=str.split) + assert msg in out + + def test_import_executable(self): + """ensure import of installed executable works""" + python = self.spec["python"].command + + out = python("-c", "import sys; print(sys.executable)", output=str.split, error=str.split) + assert self.spec.prefix in out -- cgit v1.2.3-70-g09d2