Skip to content

Commit beb9a31

Browse files
committed
move mock layout fixtures into conftest
1 parent ad92533 commit beb9a31

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

lib/spack/spack/test/conftest.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,29 @@ def fake_fn(self):
435435
PackageBase.fetcher = orig_fn
436436

437437

438+
class MockLayout(object):
439+
def __init__(self, root):
440+
self.root = root
441+
442+
def path_for_spec(self, spec):
443+
return '/'.join([self.root, spec.name])
444+
445+
def check_installed(self, spec):
446+
return True
447+
448+
449+
@pytest.fixture()
450+
def gen_mock_layout(tmpdir):
451+
# Generate a MockLayout in a temporary directory. In general the prefixes
452+
# specified by MockLayout should never be written to, but this ensures
453+
# that even if they are, that it causes no harm
454+
def create_layout(root):
455+
subroot = tmpdir.mkdir(root)
456+
return MockLayout(str(subroot))
457+
458+
yield create_layout
459+
460+
438461
@pytest.fixture()
439462
def module_configuration(monkeypatch, request):
440463
"""Reads the module configuration file from the mock ones prepared

lib/spack/spack/test/database.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,6 @@
2626
pytestmark = pytest.mark.db
2727

2828

29-
class MockLayout(object):
30-
def __init__(self, root):
31-
self.root = root
32-
33-
def path_for_spec(self, spec):
34-
return self.root + '/'.join(['test_upstream_root', spec.name])
35-
36-
def check_installed(self, spec):
37-
return True
38-
39-
40-
@pytest.fixture()
41-
def gen_mock_layout(tmpdir):
42-
# Generate a MockLayout in a temporary directory. In general the prefixes
43-
# specified by MockLayout should never be written to, but this ensures
44-
# that even if they are, that it causes no harm
45-
def create_layout(root):
46-
subroot = tmpdir.mkdir(root)
47-
return MockLayout(str(subroot))
48-
49-
yield create_layout
50-
51-
5229
@pytest.fixture()
5330
def test_store(tmpdir):
5431
real_store = spack.store.store

lib/spack/spack/test/install.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import spack.repo
1111
import spack.store
1212
from spack.spec import Spec
13-
from spack.test.database import gen_mock_layout # NOQA: ignore=F401
1413

1514

1615
def test_install_and_uninstall(install_mockery, mock_fetch):
@@ -127,7 +126,7 @@ def test_installed_dependency_request_conflicts(
127126

128127

129128
def test_installed_upstream_external(
130-
tmpdir_factory, install_mockery, mock_fetch, gen_mock_layout): # NOQA: ignore=F811
129+
tmpdir_factory, install_mockery, mock_fetch, gen_mock_layout):
131130
"""Check that when a dependency package is recorded as installed in
132131
an upstream database that it is not reinstalled.
133132
"""
@@ -162,7 +161,7 @@ def test_installed_upstream_external(
162161

163162

164163
def test_installed_upstream(tmpdir_factory, install_mockery, mock_fetch,
165-
gen_mock_layout): # NOQA: ignore=F811
164+
gen_mock_layout):
166165
"""Check that when a dependency package is recorded as installed in
167166
an upstream database that it is not reinstalled.
168167
"""

0 commit comments

Comments
 (0)