mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
test: Use read_text() and read_bytes()
This commit is contained in:
@@ -26,7 +26,7 @@ def with_text_app(*args, **kw):
|
||||
@with_text_app()
|
||||
def test_maxwitdh_with_prefix(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'maxwidth.txt').text()
|
||||
result = (app.outdir / 'maxwidth.txt').read_text()
|
||||
|
||||
lines = result.splitlines()
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
@@ -49,7 +49,7 @@ def test_maxwitdh_with_prefix(app, status, warning):
|
||||
def test_lineblock(app, status, warning):
|
||||
# regression test for #1109: need empty line after line block
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'lineblock.txt').text()
|
||||
result = (app.outdir / 'lineblock.txt').read_text()
|
||||
expect = (
|
||||
"* one\n"
|
||||
"\n"
|
||||
@@ -64,7 +64,7 @@ def test_lineblock(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_title_line(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_title.txt').text()
|
||||
result = (app.outdir / 'nonascii_title.txt').read_text()
|
||||
expect_underline = '*********'
|
||||
result_underline = result.splitlines()[1].strip()
|
||||
assert expect_underline == result_underline
|
||||
@@ -73,7 +73,7 @@ def test_nonascii_title_line(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_table(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_table.txt').text()
|
||||
result = (app.outdir / 'nonascii_table.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
assert len(set(line_widths)) == 1 # same widths
|
||||
@@ -82,7 +82,7 @@ def test_nonascii_table(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_nonascii_maxwidth(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'nonascii_maxwidth.txt').text()
|
||||
result = (app.outdir / 'nonascii_maxwidth.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
line_widths = [column_width(line) for line in lines]
|
||||
assert max(line_widths) < MAXWIDTH
|
||||
@@ -126,7 +126,7 @@ def test_table_cell():
|
||||
@with_text_app()
|
||||
def test_table_with_empty_cell(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table.txt').text()
|
||||
result = (app.outdir / 'table.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -140,7 +140,7 @@ def test_table_with_empty_cell(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_rowspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_rowspan.txt').text()
|
||||
result = (app.outdir / 'table_rowspan.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXXXXXXXX |"
|
||||
@@ -154,7 +154,7 @@ def test_table_with_rowspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan.txt').text()
|
||||
result = (app.outdir / 'table_colspan.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -168,7 +168,7 @@ def test_table_with_colspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_left(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan_left.txt').text()
|
||||
result = (app.outdir / 'table_colspan_left.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert lines[0] == "+-------+-------+"
|
||||
assert lines[1] == "| XXX | XXX |"
|
||||
@@ -182,7 +182,7 @@ def test_table_with_colspan_left(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'table_colspan_and_rowspan.txt').text()
|
||||
result = (app.outdir / 'table_colspan_and_rowspan.txt').read_text()
|
||||
lines = [line.strip() for line in result.splitlines() if line.strip()]
|
||||
assert result
|
||||
assert lines[0] == "+-------+-------+-------+"
|
||||
@@ -197,7 +197,7 @@ def test_table_with_colspan_and_rowspan(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_list_items_in_admonition(app, status, warning):
|
||||
app.builder.build_update()
|
||||
result = (app.outdir / 'listitems.txt').text()
|
||||
result = (app.outdir / 'listitems.txt').read_text()
|
||||
lines = [line.rstrip() for line in result.splitlines()]
|
||||
assert lines[0] == "See also:"
|
||||
assert lines[1] == ""
|
||||
@@ -209,7 +209,7 @@ def test_list_items_in_admonition(app, status, warning):
|
||||
@with_text_app()
|
||||
def test_secnums(app, status, warning):
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').text(encoding='utf8')
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* 1. Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -218,7 +218,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * 2.1. Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * 2.2. Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"2. Section B\n"
|
||||
"************\n"
|
||||
@@ -235,7 +235,7 @@ def test_secnums(app, status, warning):
|
||||
|
||||
app.config.text_secnumber_suffix = " "
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').text(encoding='utf8')
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* 1 Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -244,7 +244,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * 2.1 Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * 2.2 Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"2 Section B\n"
|
||||
"***********\n"
|
||||
@@ -261,7 +261,7 @@ def test_secnums(app, status, warning):
|
||||
|
||||
app.config.text_add_secnumbers = False
|
||||
app.builder.build_all()
|
||||
index = (app.outdir / 'index.txt').text(encoding='utf8')
|
||||
index = (app.outdir / 'index.txt').read_text(encoding='utf8')
|
||||
lines = index.splitlines()
|
||||
assert lines[0] == "* Section A"
|
||||
assert lines[1] == ""
|
||||
@@ -270,7 +270,7 @@ def test_secnums(app, status, warning):
|
||||
assert lines[4] == " * Sub Ba"
|
||||
assert lines[5] == ""
|
||||
assert lines[6] == " * Sub Bb"
|
||||
doc2 = (app.outdir / 'doc2.txt').text(encoding='utf8')
|
||||
doc2 = (app.outdir / 'doc2.txt').read_text(encoding='utf8')
|
||||
expect = (
|
||||
"Section B\n"
|
||||
"*********\n"
|
||||
|
||||
Reference in New Issue
Block a user