Fix all BytesWarning identified through tests

Code should not arbitrarily mix bytes & str values. The values should be
understood and deliberate. When Python is run with the -b option, this
change fixes warnings of the form:

  BytesWarning: str() on a bytes instance
This commit is contained in:
Jon Dufresne 2018-11-12 11:21:22 -08:00
parent 45ad2e41a5
commit 41ad0d5347
2 changed files with 15 additions and 15 deletions

View File

@ -456,7 +456,7 @@ class StandaloneHTMLBuilder(Builder):
"""Utility: Render a lone doctree node.""" """Utility: Render a lone doctree node."""
if node is None: if node is None:
return {'fragment': ''} return {'fragment': ''}
doc = new_document(b'<partial node>') doc = new_document('<partial node>')
doc.append(node) doc.append(node)
if self._publisher is None: if self._publisher is None:

View File

@ -54,8 +54,8 @@ def setup_command(request, tempdir, rootdir):
def test_build_sphinx(setup_command): def test_build_sphinx(setup_command):
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode == 0 assert proc.returncode == 0
@ -63,8 +63,8 @@ def test_build_sphinx(setup_command):
def test_build_sphinx_multiple_builders(setup_command): def test_build_sphinx_multiple_builders(setup_command):
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode == 0 assert proc.returncode == 0
@ -72,8 +72,8 @@ def test_build_sphinx_multiple_builders(setup_command):
def test_build_sphinx_multiple_invalid_builders(setup_command): def test_build_sphinx_multiple_invalid_builders(setup_command):
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode == 1 assert proc.returncode == 1
@ -106,8 +106,8 @@ def nonascii_srcdir(request, setup_command):
def test_build_sphinx_with_nonascii_path(setup_command): def test_build_sphinx_with_nonascii_path(setup_command):
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode == 0 assert proc.returncode == 0
@ -118,8 +118,8 @@ def test_build_sphinx_return_nonzero_status(setup_command):
'http://localhost.unexistentdomain/index.html') 'http://localhost.unexistentdomain/index.html')
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode != 0, 'expect non-zero status for setup.py' assert proc.returncode != 0, 'expect non-zero status for setup.py'
@ -129,8 +129,8 @@ def test_build_sphinx_warning_return_zero_status(setup_command):
'See :ref:`unexisting-reference-label`') 'See :ref:`unexisting-reference-label`')
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode == 0 assert proc.returncode == 0
@ -141,6 +141,6 @@ def test_build_sphinx_warning_is_error_return_nonzero_status(setup_command):
'See :ref:`unexisting-reference-label`') 'See :ref:`unexisting-reference-label`')
proc = setup_command.proc proc = setup_command.proc
out, err = proc.communicate() out, err = proc.communicate()
print(out) print(out.decode())
print(err) print(err.decode())
assert proc.returncode != 0, 'expect non-zero status for setup.py' assert proc.returncode != 0, 'expect non-zero status for setup.py'