mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Use standard `file:line: warning: message` format for warning messages.
This commit is contained in:
@@ -53,7 +53,7 @@ def test_output():
|
||||
|
||||
old_count = app._warncount
|
||||
app.warn("Bad news!")
|
||||
assert warnings.getvalue() == "WARNING: Bad news!\n"
|
||||
assert warnings.getvalue() == "warning: Bad news!\n"
|
||||
assert app._warncount == old_count + 1
|
||||
finally:
|
||||
app.cleanup()
|
||||
|
||||
@@ -36,6 +36,7 @@ def setup_module():
|
||||
platform = '',
|
||||
deprecated = False,
|
||||
members = [],
|
||||
member_order = 'alphabetic',
|
||||
)
|
||||
|
||||
directive = Struct(
|
||||
|
||||
@@ -38,24 +38,24 @@ html_warnfile = StringIO()
|
||||
latex_warnfile = StringIO()
|
||||
|
||||
ENV_WARNINGS = """\
|
||||
WARNING: %(root)s/images.txt:9: Image file not readable: foo.png
|
||||
WARNING: %(root)s/images.txt:23: Nonlocal image URI found: \
|
||||
%(root)s/images.txt:9: warning: image file not readable: foo.png
|
||||
%(root)s/images.txt:23: warning: nonlocal image URI found: \
|
||||
http://www.python.org/logo.png
|
||||
WARNING: %(root)s/includes.txt:: (WARNING/2) Encoding 'utf-8' used for reading \
|
||||
%(root)s/includes.txt:: (WARNING/2) Encoding 'utf-8' used for reading \
|
||||
included file u'wrongenc.inc' seems to be wrong, try giving an :encoding: option
|
||||
WARNING: %(root)s/includes.txt:56: Download file not readable: nonexisting.png
|
||||
%(root)s/includes.txt:56: warning: download file not readable: nonexisting.png
|
||||
"""
|
||||
|
||||
HTML_WARNINGS = ENV_WARNINGS + """\
|
||||
WARNING: %(root)s/images.txt:: no matching candidate for image URI u'foo.*'
|
||||
WARNING: %(root)s/markup.txt:: invalid index entry u''
|
||||
WARNING: %(root)s/markup.txt:: invalid pair index entry u''
|
||||
WARNING: %(root)s/markup.txt:: invalid pair index entry u'keyword; '
|
||||
%(root)s/images.txt:20: warning: no matching candidate for image URI u'foo.*'
|
||||
%(root)s/markup.txt:: warning: invalid index entry u''
|
||||
%(root)s/markup.txt:: warning: invalid pair index entry u''
|
||||
%(root)s/markup.txt:: warning: invalid pair index entry u'keyword; '
|
||||
"""
|
||||
|
||||
LATEX_WARNINGS = ENV_WARNINGS + """\
|
||||
WARNING: None:: no matching candidate for image URI u'foo.*'
|
||||
WARNING: invalid pair index entry u''
|
||||
None:None: warning: no matching candidate for image URI u'foo.*'
|
||||
warning: invalid pair index entry u''
|
||||
"""
|
||||
|
||||
HTML_XPATH = {
|
||||
|
||||
@@ -22,14 +22,14 @@ def setup_module():
|
||||
global app, env
|
||||
app = TestApp(srcdir='(temp)')
|
||||
env = BuildEnvironment(app.srcdir, app.doctreedir, app.config)
|
||||
env.set_warnfunc(warnings.append)
|
||||
env.set_warnfunc(lambda *args: warnings.append(args))
|
||||
|
||||
def teardown_module():
|
||||
app.cleanup()
|
||||
|
||||
def warning_emitted(file, text):
|
||||
for warning in warnings:
|
||||
if file+':' in warning and text in warning:
|
||||
if len(warning) == 2 and file+':' in warning[1] and text in warning[0]:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -46,8 +46,8 @@ def test_first_update():
|
||||
assert docnames == env.found_docs == set(env.all_docs)
|
||||
|
||||
def test_images():
|
||||
assert warning_emitted('images.txt', 'Image file not readable: foo.png')
|
||||
assert warning_emitted('images.txt', 'Nonlocal image URI found: '
|
||||
assert warning_emitted('images.txt', 'image file not readable: foo.png')
|
||||
assert warning_emitted('images.txt', 'nonlocal image URI found: '
|
||||
'http://www.python.org/logo.png')
|
||||
|
||||
tree = env.get_doctree('images')
|
||||
|
||||
Reference in New Issue
Block a user