Make MockPackagesTest use a different module location.

- ensures anything tests create is blown away.
This commit is contained in:
Todd Gamblin 2016-06-27 01:22:03 -07:00
parent 3bc4a38b78
commit a15aee5d8e
3 changed files with 12 additions and 7 deletions

View file

@ -454,7 +454,6 @@ def remove(self):
class Dotkit(EnvModule):
name = 'dotkit'
path = join_path(spack.share_path, "dotkit")
environment_modifications_formats = {
PrependPath: 'dk_alter {name} {value}\n',
@ -467,7 +466,7 @@ class Dotkit(EnvModule):
@property
def file_name(self):
return join_path(Dotkit.path, self.spec.architecture,
return join_path(spack.share_path, "dotkit", self.spec.architecture,
'%s.dk' % self.use_name)
@property
@ -495,7 +494,6 @@ def prerequisite(self, spec):
class TclModule(EnvModule):
name = 'tcl'
path = join_path(spack.share_path, "modules")
environment_modifications_formats = {
PrependPath: 'prepend-path --delim "{delim}" {name} \"{value}\"\n',
@ -516,7 +514,7 @@ class TclModule(EnvModule):
@property
def file_name(self):
return join_path(TclModule.path, self.spec.architecture, self.use_name)
return join_path(spack.share_path, "modules", self.spec.architecture, self.use_name)
@property
def header(self):

View file

@ -201,6 +201,10 @@ def initmock(self):
spack.config.ConfigScope('site', self.mock_site_config)
spack.config.ConfigScope('user', self.mock_user_config)
# Keep tests from interfering with the actual module path.
self.real_share_path = spack.share_path
spack.share_path = tempfile.mkdtemp()
# Store changes to the package's dependencies so we can
# restore later.
self.saved_deps = {}
@ -235,6 +239,9 @@ def cleanmock(self):
pkg.dependencies.clear()
pkg.dependencies.update(deps)
shutil.rmtree(spack.share_path, ignore_errors=True)
spack.share_path = self.real_share_path
def setUp(self):
self.initmock()

View file

@ -148,7 +148,7 @@ def mock_open(filename, mode):
}
class HelperFunctionsTests(unittest.TestCase):
class HelperFunctionsTests(MockPackagesTest):
def test_update_dictionary_extending_list(self):
target = {