test/python_version.py: ported to pytest (#3438)
This commit is contained in:
parent
a65c37f15d
commit
50d7b33563
@ -36,7 +36,6 @@
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import unittest
|
||||
|
||||
import llnl.util.tty as tty
|
||||
import spack
|
||||
@ -65,11 +64,13 @@
|
||||
os.path.join(spack.lib_path, 'external', 'pyqver2.py')]
|
||||
|
||||
|
||||
class PythonVersionTest(unittest.TestCase):
|
||||
def pyfiles(search_paths, exclude=()):
|
||||
"""Generator that yields all the python files in the search paths.
|
||||
|
||||
def pyfiles(self, search_paths, exclude=()):
|
||||
"""List python search files in a set of search paths, excluding
|
||||
any paths in the exclude list"""
|
||||
:param search_paths: list of paths to search for python files
|
||||
:param exclude: file paths to exclude from search
|
||||
:return: python files
|
||||
"""
|
||||
# first file is the spack script.
|
||||
yield spack.spack_file
|
||||
|
||||
@ -84,7 +85,9 @@ def pyfiles(self, search_paths, exclude=()):
|
||||
if re.match(r'^[^.#].*\.py$', filename):
|
||||
yield os.path.join(root, filename)
|
||||
|
||||
def check_python_versions(self, files):
|
||||
|
||||
def check_python_versions(files):
|
||||
"""Check that a set of Python files works with supported Ptyhon versions"""
|
||||
# This is a dict dict mapping:
|
||||
# version -> filename -> reasons
|
||||
#
|
||||
@ -137,11 +140,14 @@ def check_python_versions(self, files):
|
||||
print(fmt % msg)
|
||||
|
||||
# Fail this test if there were issues.
|
||||
self.assertTrue(len(all_issues) == 0)
|
||||
assert not all_issues
|
||||
|
||||
def test_core_module_compatibility(self):
|
||||
self.check_python_versions(
|
||||
self.pyfiles([spack.lib_path], exclude=exclude_paths))
|
||||
|
||||
def test_package_module_compatibility(self):
|
||||
self.check_python_versions(self.pyfiles([spack.packages_path]))
|
||||
def test_core_module_compatibility():
|
||||
"""Test that all core spack modules work with supported Python versions."""
|
||||
check_python_versions(pyfiles([spack.lib_path], exclude=exclude_paths))
|
||||
|
||||
|
||||
def test_package_module_compatibility():
|
||||
"""Test that all spack packages work with supported Python versions."""
|
||||
check_python_versions(pyfiles([spack.packages_path]))
|
||||
|
Loading…
Reference in New Issue
Block a user