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
@ -2551,11 +2551,12 @@ def _run_default_build_time_test_callbacks(self):
|
|||||||
for name in self.build_time_test_callbacks:
|
for name in self.build_time_test_callbacks:
|
||||||
try:
|
try:
|
||||||
fn = getattr(self, name)
|
fn = getattr(self, name)
|
||||||
tty.msg('RUN-TESTS: build-time tests [{0}]'.format(name))
|
|
||||||
fn()
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
msg = 'RUN-TESTS: method not implemented [{0}]'
|
msg = 'RUN-TESTS: method not implemented [{0}]'
|
||||||
tty.warn(msg.format(name))
|
tty.warn(msg.format(name))
|
||||||
|
else:
|
||||||
|
tty.msg('RUN-TESTS: build-time tests [{0}]'.format(name))
|
||||||
|
fn()
|
||||||
|
|
||||||
@on_package_attributes(run_tests=True)
|
@on_package_attributes(run_tests=True)
|
||||||
def _run_default_install_time_test_callbacks(self):
|
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:
|
for name in self.install_time_test_callbacks:
|
||||||
try:
|
try:
|
||||||
fn = getattr(self, name)
|
fn = getattr(self, name)
|
||||||
tty.msg('RUN-TESTS: install-time tests [{0}]'.format(name))
|
|
||||||
fn()
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
msg = 'RUN-TESTS: method not implemented [{0}]'
|
msg = 'RUN-TESTS: method not implemented [{0}]'
|
||||||
tty.warn(msg.format(name))
|
tty.warn(msg.format(name))
|
||||||
|
else:
|
||||||
|
tty.msg('RUN-TESTS: install-time tests [{0}]'.format(name))
|
||||||
|
fn()
|
||||||
|
|
||||||
|
|
||||||
def test_process(pkg, kwargs):
|
def test_process(pkg, kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user