diff options
author | Massimiliano Culpo <massimiliano.culpo@googlemail.com> | 2017-03-31 22:42:04 +0200 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2017-03-31 13:42:04 -0700 |
commit | 0c44dd28bb85b874ddd109974ff3585b78d85ec4 (patch) | |
tree | d64abef8845ffc81549c8bf0f62adfbcaa8c1141 | |
parent | ee7753a597f7c180338330b4c269901f97e343bc (diff) | |
download | spack-0c44dd28bb85b874ddd109974ff3585b78d85ec4.tar.gz spack-0c44dd28bb85b874ddd109974ff3585b78d85ec4.tar.bz2 spack-0c44dd28bb85b874ddd109974ff3585b78d85ec4.tar.xz spack-0c44dd28bb85b874ddd109974ff3585b78d85ec4.zip |
test/package_sanity.py: ported to pytest (#3474)
-rw-r--r-- | lib/spack/spack/test/package_sanity.py | 67 |
1 files changed, 33 insertions, 34 deletions
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 |