Fix error message when test throws AttributeError (#25895)
Narrow the scope of the try/except block, to avoid a misleading error message if fn() throws an AttributeError.
This commit is contained in:
parent
d19105f761
commit
b6169c213d
1 changed files with 6 additions and 4 deletions
|
@ -2551,11 +2551,12 @@ def _run_default_build_time_test_callbacks(self):
|
|||
for name in self.build_time_test_callbacks:
|
||||
try:
|
||||
fn = getattr(self, name)
|
||||
tty.msg('RUN-TESTS: build-time tests [{0}]'.format(name))
|
||||
fn()
|
||||
except AttributeError:
|
||||
msg = 'RUN-TESTS: method not implemented [{0}]'
|
||||
tty.warn(msg.format(name))
|
||||
else:
|
||||
tty.msg('RUN-TESTS: build-time tests [{0}]'.format(name))
|
||||
fn()
|
||||
|
||||
@on_package_attributes(run_tests=True)
|
||||
def _run_default_install_time_test_callbacks(self):
|
||||
|
@ -2570,11 +2571,12 @@ def _run_default_install_time_test_callbacks(self):
|
|||
for name in self.install_time_test_callbacks:
|
||||
try:
|
||||
fn = getattr(self, name)
|
||||
tty.msg('RUN-TESTS: install-time tests [{0}]'.format(name))
|
||||
fn()
|
||||
except AttributeError:
|
||||
msg = 'RUN-TESTS: method not implemented [{0}]'
|
||||
tty.warn(msg.format(name))
|
||||
else:
|
||||
tty.msg('RUN-TESTS: install-time tests [{0}]'.format(name))
|
||||
fn()
|
||||
|
||||
|
||||
def test_process(pkg, kwargs):
|
||||
|
|
Loading…
Reference in a new issue