diff options
| author | shimizukawa <shimizukawa@gmail.com> | 2016-12-04 13:51:53 +0900 |
|---|---|---|
| committer | shimizukawa <shimizukawa@gmail.com> | 2016-12-04 13:54:11 +0900 |
| commit | 6ae67f9f38120dd72945d2d2ca43a8af2c0a6967 (patch) | |
| tree | 6777d3d3af22fafc1e3a48f00c446b79550e15a9 /tests/test_application.py | |
| parent | 794e0801f8dea9bf8b465411964ee120432ee8e9 (diff) | |
| download | sphinx-git-6ae67f9f38120dd72945d2d2ca43a8af2c0a6967.tar.gz | |
Fix #3024, refs #3037: In Python3, application.Sphinx._log crushed when the log message cannot be encoded into console encoding.
Diffstat (limited to 'tests/test_application.py')
| -rw-r--r-- | tests/test_application.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_application.py b/tests/test_application.py index 420680451..b0ad4b8d6 100644 --- a/tests/test_application.py +++ b/tests/test_application.py @@ -8,6 +8,7 @@ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS. :license: BSD, see LICENSE for details. """ +import codecs from docutils import nodes @@ -49,15 +50,18 @@ def test_emit_with_nonascii_name_node(app, status, warning): @with_app() def test_output(app, status, warning): + # info with newline status.truncate(0) # __init__ writes to status status.seek(0) app.info("Nothing here...") assert status.getvalue() == "Nothing here...\n" + # info without newline status.truncate(0) status.seek(0) app.info("Nothing here...", True) assert status.getvalue() == "Nothing here..." + # warning old_count = app._warncount app.warn("Bad news!") assert warning.getvalue() == "WARNING: Bad news!\n" @@ -65,6 +69,22 @@ def test_output(app, status, warning): @with_app() +def test_output_with_unencodable_char(app, status, warning): + + class StreamWriter(codecs.StreamWriter): + def write(self, object): + self.stream.write(object.encode('cp1252').decode('cp1252')) + + app._status = StreamWriter(status) + + # info with UnicodeEncodeError + status.truncate(0) + status.seek(0) + app.info(u"unicode \u206d...") + assert status.getvalue() == "unicode ?...\n" + + +@with_app() def test_extensions(app, status, warning): app.setup_extension('shutil') assert warning.getvalue().startswith("WARNING: extension 'shutil'") |
