Fix B904 (raise exceptions with `raise ... from ...`)

This commit is contained in:
Adam Turner
2023-08-13 17:37:51 +01:00
committed by Adam Turner
parent db6d5aee2c
commit e010e24728
8 changed files with 13 additions and 15 deletions

View File

@@ -385,7 +385,7 @@ def test_run_epubcheck(app):
except CalledProcessError as exc:
print(exc.stdout.decode('utf-8'))
print(exc.stderr.decode('utf-8'))
raise AssertionError('epubcheck exited with return code %s' % exc.returncode)
raise AssertionError(f'epubcheck exited with return code {exc.returncode}') from exc
def test_xml_name_pattern_check():

View File

@@ -74,7 +74,7 @@ def test_msgfmt(app):
except CalledProcessError as exc:
print(exc.stdout)
print(exc.stderr)
raise AssertionError('msginit exited with return code %s' % exc.returncode)
raise AssertionError(f'msginit exited with return code {exc.returncode}') from exc
assert (app.outdir / 'en_US.po').is_file(), 'msginit failed'
try:
@@ -86,7 +86,7 @@ def test_msgfmt(app):
except CalledProcessError as exc:
print(exc.stdout)
print(exc.stderr)
raise AssertionError('msgfmt exited with return code %s' % exc.returncode)
raise AssertionError(f'msgfmt exited with return code {exc.returncode}') from exc
mo = app.outdir / 'en' / 'LC_MESSAGES' / 'test_root.mo'
assert mo.is_file(), 'msgfmt failed'

View File

@@ -73,7 +73,7 @@ def compile_latex_document(app, filename='python.tex', docclass='manual'):
print(exc.stdout.decode('utf8'))
print(exc.stderr.decode('utf8'))
raise AssertionError(f'{app.config.latex_engine} exited with '
f'return code {exc.returncode}')
f'return code {exc.returncode}') from exc
def skip_if_requested(testfunc):

View File

@@ -56,7 +56,7 @@ def test_texinfo(app, status, warning):
except CalledProcessError as exc:
print(exc.stdout)
print(exc.stderr)
raise AssertionError('makeinfo exited with return code %s' % exc.retcode)
raise AssertionError(f'makeinfo exited with return code {exc.retcode}') from exc
@pytest.mark.sphinx('texinfo', testroot='markup-rubric')