mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Test suite fixes after env.update() change.
This commit is contained in:
parent
31452fc64d
commit
7bbaa4c73f
@ -20,7 +20,7 @@ import traceback
|
|||||||
from os import path
|
from os import path
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from six import iteritems, itervalues
|
from six import iteritems, itervalues, text_type
|
||||||
from six.moves import cStringIO
|
from six.moves import cStringIO
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
from docutils.parsers.rst import convert_directive_function, \
|
from docutils.parsers.rst import convert_directive_function, \
|
||||||
@ -356,9 +356,9 @@ class Sphinx(object):
|
|||||||
def _display_chunk(chunk):
|
def _display_chunk(chunk):
|
||||||
if isinstance(chunk, (list, tuple)):
|
if isinstance(chunk, (list, tuple)):
|
||||||
if len(chunk) == 1:
|
if len(chunk) == 1:
|
||||||
return str(chunk[0])
|
return text_type(chunk[0])
|
||||||
return '%s .. %s' % (chunk[0], chunk[-1])
|
return '%s .. %s' % (chunk[0], chunk[-1])
|
||||||
return str(chunk)
|
return text_type(chunk)
|
||||||
|
|
||||||
def old_status_iterator(self, iterable, summary, colorfunc=darkgreen,
|
def old_status_iterator(self, iterable, summary, colorfunc=darkgreen,
|
||||||
stringify_func=_display_chunk):
|
stringify_func=_display_chunk):
|
||||||
|
@ -42,12 +42,8 @@ def warning_emitted(file, text):
|
|||||||
# afford to not run update() in the setup but in its own test
|
# afford to not run update() in the setup but in its own test
|
||||||
|
|
||||||
def test_first_update():
|
def test_first_update():
|
||||||
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
|
updated = env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
assert msg.endswith('%d added, 0 changed, 0 removed' % len(env.found_docs))
|
assert set(updated) == env.found_docs == set(env.all_docs)
|
||||||
docnames = set()
|
|
||||||
for docname in it: # the generator does all the work
|
|
||||||
docnames.add(docname)
|
|
||||||
assert docnames == env.found_docs == set(env.all_docs)
|
|
||||||
# test if exclude_patterns works ok
|
# test if exclude_patterns works ok
|
||||||
assert 'subdir/excluded' not in env.found_docs
|
assert 'subdir/excluded' not in env.found_docs
|
||||||
|
|
||||||
@ -90,15 +86,11 @@ def test_second_update():
|
|||||||
# the contents.txt toctree; otherwise section numbers would shift
|
# the contents.txt toctree; otherwise section numbers would shift
|
||||||
(root / 'autodoc.txt').unlink()
|
(root / 'autodoc.txt').unlink()
|
||||||
(root / 'new.txt').write_text('New file\n========\n')
|
(root / 'new.txt').write_text('New file\n========\n')
|
||||||
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
|
updated = env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
assert '1 added, 3 changed, 1 removed' in msg
|
|
||||||
docnames = set()
|
|
||||||
for docname in it:
|
|
||||||
docnames.add(docname)
|
|
||||||
# "includes" and "images" are in there because they contain references
|
# "includes" and "images" are in there because they contain references
|
||||||
# to nonexisting downloadable or image files, which are given another
|
# to nonexisting downloadable or image files, which are given another
|
||||||
# chance to exist
|
# chance to exist
|
||||||
assert docnames == set(['contents', 'new', 'includes', 'images'])
|
assert set(updated) == set(['contents', 'new', 'includes', 'images'])
|
||||||
assert 'autodoc' not in env.all_docs
|
assert 'autodoc' not in env.all_docs
|
||||||
assert 'autodoc' not in env.found_docs
|
assert 'autodoc' not in env.found_docs
|
||||||
|
|
||||||
@ -110,8 +102,7 @@ def test_env_read_docs():
|
|||||||
|
|
||||||
app.connect('env-before-read-docs', on_env_read_docs_1)
|
app.connect('env-before-read-docs', on_env_read_docs_1)
|
||||||
|
|
||||||
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
|
read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
read_docnames = [docname for docname in it]
|
|
||||||
assert len(read_docnames) > 2 and read_docnames == sorted(read_docnames)
|
assert len(read_docnames) > 2 and read_docnames == sorted(read_docnames)
|
||||||
|
|
||||||
def on_env_read_docs_2(app, env, docnames):
|
def on_env_read_docs_2(app, env, docnames):
|
||||||
@ -119,8 +110,7 @@ def test_env_read_docs():
|
|||||||
|
|
||||||
app.connect('env-before-read-docs', on_env_read_docs_2)
|
app.connect('env-before-read-docs', on_env_read_docs_2)
|
||||||
|
|
||||||
msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app)
|
read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
read_docnames = [docname for docname in it]
|
|
||||||
reversed_read_docnames = sorted(read_docnames, reverse=True)
|
reversed_read_docnames = sorted(read_docnames, reverse=True)
|
||||||
assert len(read_docnames) > 2 and read_docnames == reversed_read_docnames
|
assert len(read_docnames) > 2 and read_docnames == reversed_read_docnames
|
||||||
|
|
||||||
|
@ -386,12 +386,12 @@ def test_html_builder(app, status, warning):
|
|||||||
# --- rebuild by .mo mtime
|
# --- rebuild by .mo mtime
|
||||||
|
|
||||||
app.builder.build_update()
|
app.builder.build_update()
|
||||||
_, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app)
|
updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
yield assert_equal, count, 0
|
yield assert_equal, len(updated), 0
|
||||||
|
|
||||||
(app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
|
(app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None)
|
||||||
_, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app)
|
updated = app.env.update(app.config, app.srcdir, app.doctreedir, app)
|
||||||
yield assert_equal, count, 1
|
yield assert_equal, len(updated), 1
|
||||||
|
|
||||||
|
|
||||||
@gen_with_intl_app('xml', freshenv=True)
|
@gen_with_intl_app('xml', freshenv=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user