diff --git a/sphinx/application.py b/sphinx/application.py index f7ff95175..ff4d45b0a 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -20,7 +20,7 @@ import traceback from os import path from collections import deque -from six import iteritems, itervalues +from six import iteritems, itervalues, text_type from six.moves import cStringIO from docutils import nodes from docutils.parsers.rst import convert_directive_function, \ @@ -356,9 +356,9 @@ class Sphinx(object): def _display_chunk(chunk): if isinstance(chunk, (list, tuple)): if len(chunk) == 1: - return str(chunk[0]) + return text_type(chunk[0]) return '%s .. %s' % (chunk[0], chunk[-1]) - return str(chunk) + return text_type(chunk) def old_status_iterator(self, iterable, summary, colorfunc=darkgreen, stringify_func=_display_chunk): diff --git a/tests/test_environment.py b/tests/test_environment.py index 97217aeaf..b5da325f5 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -42,12 +42,8 @@ def warning_emitted(file, text): # afford to not run update() in the setup but in its own test def test_first_update(): - msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app) - assert msg.endswith('%d added, 0 changed, 0 removed' % len(env.found_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) + updated = env.update(app.config, app.srcdir, app.doctreedir, app) + assert set(updated) == env.found_docs == set(env.all_docs) # test if exclude_patterns works ok 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 (root / 'autodoc.txt').unlink() (root / 'new.txt').write_text('New file\n========\n') - msg, num, it = 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) + updated = env.update(app.config, app.srcdir, app.doctreedir, app) # "includes" and "images" are in there because they contain references # to nonexisting downloadable or image files, which are given another # 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.found_docs @@ -110,8 +102,7 @@ def test_env_read_docs(): 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 = [docname for docname in it] + read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app) assert len(read_docnames) > 2 and read_docnames == sorted(read_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) - msg, num, it = env.update(app.config, app.srcdir, app.doctreedir, app) - read_docnames = [docname for docname in it] + read_docnames = env.update(app.config, app.srcdir, app.doctreedir, app) reversed_read_docnames = sorted(read_docnames, reverse=True) assert len(read_docnames) > 2 and read_docnames == reversed_read_docnames diff --git a/tests/test_intl.py b/tests/test_intl.py index 67dd02dea..69437c1a7 100644 --- a/tests/test_intl.py +++ b/tests/test_intl.py @@ -386,12 +386,12 @@ def test_html_builder(app, status, warning): # --- rebuild by .mo mtime app.builder.build_update() - _, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app) - yield assert_equal, count, 0 + updated = app.env.update(app.config, app.srcdir, app.doctreedir, app) + yield assert_equal, len(updated), 0 (app.srcdir / 'xx' / 'LC_MESSAGES' / 'bom.mo').utime(None) - _, count, _ = app.env.update(app.config, app.srcdir, app.doctreedir, app) - yield assert_equal, count, 1 + updated = app.env.update(app.config, app.srcdir, app.doctreedir, app) + yield assert_equal, len(updated), 1 @gen_with_intl_app('xml', freshenv=True)