ci: fix issue with latest sphinx (#20661)
This commit is contained in:
parent
11dd7ffad6
commit
cfd0ff52d1
2 changed files with 17 additions and 1 deletions
|
@ -118,7 +118,11 @@ def __init__(self, namespace):
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""Getattr lazily loads modules if they're not already loaded."""
|
"""Getattr lazily loads modules if they're not already loaded."""
|
||||||
submodule = self.__package__ + '.' + name
|
submodule = self.__package__ + '.' + name
|
||||||
setattr(self, name, __import__(submodule))
|
try:
|
||||||
|
setattr(self, name, __import__(submodule))
|
||||||
|
except ImportError:
|
||||||
|
msg = "'{0}' object has no attribute {1}"
|
||||||
|
raise AttributeError(msg.format(type(self), name))
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,3 +67,15 @@ def test_repo_invisibles(mutable_mock_repo, extra_repo):
|
||||||
with open(os.path.join(extra_repo.root, 'packages', '.invisible'), 'w'):
|
with open(os.path.join(extra_repo.root, 'packages', '.invisible'), 'w'):
|
||||||
pass
|
pass
|
||||||
extra_repo.all_package_names()
|
extra_repo.all_package_names()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('attr_name,exists', [
|
||||||
|
('cmake', True),
|
||||||
|
('__sphinx_mock__', False)
|
||||||
|
])
|
||||||
|
@pytest.mark.regression('20661')
|
||||||
|
def test_namespace_hasattr(attr_name, exists, mutable_mock_repo):
|
||||||
|
# Check that we don't fail on 'hasattr' checks because
|
||||||
|
# of a custom __getattr__ implementation
|
||||||
|
nms = spack.repo.SpackNamespace('spack.pkg.builtin.mock')
|
||||||
|
assert hasattr(nms, attr_name) == exists
|
||||||
|
|
Loading…
Reference in a new issue