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:
Cory Bloor 2021-10-01 17:40:24 -06:00 committed by GitHub
parent d19105f761
commit b6169c213d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):