From 0c44dd28bb85b874ddd109974ff3585b78d85ec4 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Fri, 31 Mar 2017 22:42:04 +0200 Subject: test/package_sanity.py: ported to pytest (#3474) --- lib/spack/spack/test/package_sanity.py | 67 +++++++++++++++++----------------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/test/package_sanity.py b/lib/spack/spack/test/package_sanity.py index c75d7cdcc7..ac318f94dc 100644 --- a/lib/spack/spack/test/package_sanity.py +++ b/lib/spack/spack/test/package_sanity.py @@ -22,49 +22,48 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################## -"""\ -This test does sanity checks on Spack's builtin package database. -""" -import unittest +"""This test does sanity checks on Spack's builtin package database.""" + import re import spack from spack.repository import RepoPath -class PackageSanityTest(unittest.TestCase): +def check_db(): + """Get all packages in a DB to make sure they work.""" + for name in spack.repo.all_package_names(): + spack.repo.get(name) + + +def test_get_all_packages(): + """Get all packages once and make sure that works.""" + check_db() + - def check_db(self): - """Get all packages in a DB to make sure they work.""" - for name in spack.repo.all_package_names(): - spack.repo.get(name) +def test_get_all_mock_packages(): + """Get the mock packages once each too.""" + db = RepoPath(spack.mock_packages_path) + spack.repo.swap(db) + check_db() + spack.repo.swap(db) - def test_get_all_packages(self): - """Get all packages once and make sure that works.""" - self.check_db() - def test_get_all_mock_packages(self): - """Get the mock packages once each too.""" - db = RepoPath(spack.mock_packages_path) - spack.repo.swap(db) - self.check_db() - spack.repo.swap(db) +def test_url_versions(): + """Check URLs for regular packages, if they are explicitly defined.""" + for pkg in spack.repo.all_packages(): + for v, vattrs in pkg.versions.items(): + if 'url' in vattrs: + # If there is a url for the version check it. + v_url = pkg.url_for_version(v) + assert vattrs['url'] == v_url - def test_url_versions(self): - """Check URLs for regular packages, if they are explicitly defined.""" - for pkg in spack.repo.all_packages(): - for v, vattrs in pkg.versions.items(): - if 'url' in vattrs: - # If there is a url for the version check it. - v_url = pkg.url_for_version(v) - self.assertEqual(vattrs['url'], v_url) - def test_all_versions_are_lowercase(self): - """Spack package names must be lowercase, and use `-` instead of `_`. - """ - errors = [] - for name in spack.repo.all_package_names(): - if re.search(r'[_A-Z]', name): - errors.append(name) +def test_all_versions_are_lowercase(): + """Spack package names must be lowercase, and use `-` instead of `_`.""" + errors = [] + for name in spack.repo.all_package_names(): + if re.search(r'[_A-Z]', name): + errors.append(name) - self.assertEqual([], errors) + assert len(errors) == 0 -- cgit v1.2.3-70-g09d2