diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2015-11-12 15:17:09 -0800 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2015-11-12 15:17:09 -0800 |
commit | 72c9604bcb9f0f28d0e7d63be9500b99960d118b (patch) | |
tree | d0e1939a23cb2489082e0473a4c1c0ce727625a0 | |
parent | 55662eca696352b5bbe2a0c31868b6ebb33e1c99 (diff) | |
download | spack-72c9604bcb9f0f28d0e7d63be9500b99960d118b.tar.gz spack-72c9604bcb9f0f28d0e7d63be9500b99960d118b.tar.bz2 spack-72c9604bcb9f0f28d0e7d63be9500b99960d118b.tar.xz spack-72c9604bcb9f0f28d0e7d63be9500b99960d118b.zip |
Small fix to prevent this test from interfering with others.
-rw-r--r-- | lib/spack/spack/test/unit_install.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/spack/spack/test/unit_install.py b/lib/spack/spack/test/unit_install.py index c4b9092f05..7168272997 100644 --- a/lib/spack/spack/test/unit_install.py +++ b/lib/spack/spack/test/unit_install.py @@ -26,16 +26,16 @@ import unittest import itertools import spack -test_install = __import__("spack.cmd.test-install", +test_install = __import__("spack.cmd.test-install", fromlist=["BuildId", "create_test_output", "TestResult"]) class MockOutput(object): def __init__(self): self.results = {} - + def add_test(self, buildId, passed=True, buildInfo=None): self.results[buildId] = passed - + def write_to(self, stream): pass @@ -45,14 +45,14 @@ class MockSpec(object): self.name = name self.version = version self.hash = hashStr if hashStr else hash((name, version)) - + def traverse(self, order=None): - allDeps = itertools.chain.from_iterable(i.traverse() for i in + allDeps = itertools.chain.from_iterable(i.traverse() for i in self.dependencies.itervalues()) return set(itertools.chain([self], allDeps)) - + def dag_hash(self): - return self.hash + return self.hash def to_yaml(self): return "<<<MOCK YAML {0}>>>".format(test_install.BuildId(self).stringId()) @@ -75,47 +75,52 @@ class UnitInstallTest(unittest.TestCase): def setUp(self): super(UnitInstallTest, self).setUp() - + pkgX.installed = False pkgY.installed = False + self.saved_db = spack.db pkgDb = MockPackageDb({specX:pkgX, specY:pkgY}) spack.db = pkgDb + def tearDown(self): super(UnitInstallTest, self).tearDown() - + + spack.db = self.saved_db + def test_installing_both(self): mo = MockOutput() - + pkgX.installed = True pkgY.installed = True test_install.create_test_output(specX, [specX, specY], mo, getLogFunc=test_fetch_log) - - self.assertEqual(mo.results, - {bIdX:test_install.TestResult.PASSED, + + self.assertEqual(mo.results, + {bIdX:test_install.TestResult.PASSED, bIdY:test_install.TestResult.PASSED}) + def test_dependency_already_installed(self): mo = MockOutput() - + pkgX.installed = True pkgY.installed = True test_install.create_test_output(specX, [specX], mo, getLogFunc=test_fetch_log) - + self.assertEqual(mo.results, {bIdX:test_install.TestResult.PASSED}) #TODO: add test(s) where Y fails to install + class MockPackageDb(object): def __init__(self, init=None): self.specToPkg = {} if init: self.specToPkg.update(init) - + def get(self, spec): return self.specToPkg[spec] def test_fetch_log(path): return [] - |