Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0a0bf07

Browse files
committed
Migrated tests to use read_text().
1 parent9bdb9c2 commit0a0bf07

13 files changed

+136
-166
lines changed

‎test/test_bibfile_out_of_date.py‎

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,43 @@
77
Sphinx is run again.
88
"""
99

10-
importos.path
1110
importshutil
1211
importre
1312
importtime
14-
1513
fromsphinx_testing.utilimportpath,with_app
1614

15+
1716
srcdir=path(__file__).dirname().joinpath('bibfile_out_of_date').abspath()
1817

1918

2019
defteardown_module():
2120
(srcdir/'_build').rmtree(True)
22-
os.remove(srcdir/'test.bib')
21+
(srcdir/'test.bib').rmtree(True)
2322

2423

2524
@with_app(srcdir=srcdir,warningiserror=True)
2625
deftest_encoding(app,status,warning):
27-
shutil.copyfile(
28-
os.path.join(srcdir,'test_old.bib'),
29-
os.path.join(srcdir,'test.bib'))
26+
shutil.copyfile((srcdir/'test_old.bib'), (srcdir/'test.bib'))
3027
app.builder.build_all()
31-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
32-
assertre.search(
33-
'<p>'
34-
'.*<tr><td>\\[1\\]</td><td>.*Akkerdju.*</td></tr>'
35-
'.*<tr><td>\\[2\\]</td><td>.*Bro.*</td></tr>'
36-
'.*<tr><td>\\[3\\]</td><td>.*Chap.*</td></tr>'
37-
'.*<tr><td>\\[4\\]</td><td>.*Dude.*</td></tr>'
38-
'.*</p>',
39-
stream.read(),re.MULTILINE|re.DOTALL)
28+
output= (app.outdir/"contents.html").read_text()
29+
assertre.search(
30+
'<p>'
31+
'.*<tr><td>\\[1\\]</td><td>.*Akkerdju.*</td></tr>'
32+
'.*<tr><td>\\[2\\]</td><td>.*Bro.*</td></tr>'
33+
'.*<tr><td>\\[3\\]</td><td>.*Chap.*</td></tr>'
34+
'.*<tr><td>\\[4\\]</td><td>.*Dude.*</td></tr>'
35+
'.*</p>',
36+
output,re.MULTILINE|re.DOTALL)
4037
# wait to ensure different timestamp
4138
time.sleep(0.1)
42-
shutil.copyfile(
43-
os.path.join(srcdir,'test_new.bib'),
44-
os.path.join(srcdir,'test.bib'))
39+
shutil.copyfile((srcdir/'test_new.bib'), (srcdir/'test.bib'))
4540
app.builder.build_all()
46-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
47-
assertre.search(
48-
'<p>'
49-
'.*<tr><td>\\[1\\]</td><td>.*Eminence.*</td></tr>'
50-
'.*<tr><td>\\[2\\]</td><td>.*Frater.*</td></tr>'
51-
'.*<tr><td>\\[3\\]</td><td>.*Giggles.*</td></tr>'
52-
'.*<tr><td>\\[4\\]</td><td>.*Handy.*</td></tr>'
53-
'.*</p>',
54-
stream.read(),re.MULTILINE|re.DOTALL)
41+
output= (app.outdir/"contents.html").read_text()
42+
assertre.search(
43+
'<p>'
44+
'.*<tr><td>\\[1\\]</td><td>.*Eminence.*</td></tr>'
45+
'.*<tr><td>\\[2\\]</td><td>.*Frater.*</td></tr>'
46+
'.*<tr><td>\\[3\\]</td><td>.*Giggles.*</td></tr>'
47+
'.*<tr><td>\\[4\\]</td><td>.*Handy.*</td></tr>'
48+
'.*</p>',
49+
output,re.MULTILINE|re.DOTALL)

‎test/test_custom_style.py‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test a custom style.
77
"""
88

9-
importos.path
109
importre
1110

1211
fromsphinx_testing.utilimportpath,with_app
@@ -28,8 +27,7 @@ def test_custom_style_skip():
2827
@with_app(srcdir=srcdir,warningiserror=True)
2928
deftest_custom_style(app,status,warning):
3029
app.builder.build_all()
31-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
32-
output=stream.read()
33-
# the custom style suppresses web links
34-
assertnotre.search('http://arxiv.org',output)
35-
assertnotre.search('http://dx.doi.org',output)
30+
output= (app.outdir/"contents.html").read_text()
31+
# the custom style suppresses web links
32+
assertnotre.search('http://arxiv.org',output)
33+
assertnotre.search('http://dx.doi.org',output)

‎test/test_filter.py‎

Lines changed: 41 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
Test filter option.
77
"""
88

9-
importos.path
109
importre
11-
1210
fromsphinx_testing.utilimportpath,with_app
1311

12+
1413
srcdir=path(__file__).dirname().joinpath('filter').abspath()
1514

1615

@@ -21,53 +20,43 @@ def teardown_module():
2120
@with_app(srcdir=srcdir,warningiserror=True)
2221
deftest_filter(app,status,warning):
2322
app.builder.build_all()
24-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
25-
output=stream.read()
26-
assertre.search('Tralalala',output)
27-
assertnotre.search('ideetje',output)
28-
assertnotre.search('Jakkamakka',output)
29-
withopen(os.path.join(app.outdir,"or.html"))asstream:
30-
output=stream.read()
31-
assertnotre.search('Tralalala',output)
32-
assertre.search('ideetje',output)
33-
assertre.search('Jakkamakka',output)
34-
withopen(os.path.join(app.outdir,"noteq.html"))asstream:
35-
output=stream.read()
36-
assertre.search('Tralalala',output)
37-
assertre.search('ideetje',output)
38-
assertnotre.search('Jakkamakka',output)
39-
withopen(os.path.join(app.outdir,"lt.html"))asstream:
40-
output=stream.read()
41-
assertre.search('Tralalala',output)
42-
assertnotre.search('ideetje',output)
43-
assertnotre.search('Jakkamakka',output)
44-
withopen(os.path.join(app.outdir,"lte.html"))asstream:
45-
output=stream.read()
46-
assertre.search('Tralalala',output)
47-
assertnotre.search('ideetje',output)
48-
assertre.search('Jakkamakka',output)
49-
withopen(os.path.join(app.outdir,"gt.html"))asstream:
50-
output=stream.read()
51-
assertnotre.search('Tralalala',output)
52-
assertre.search('ideetje',output)
53-
assertnotre.search('Jakkamakka',output)
54-
withopen(os.path.join(app.outdir,"gte.html"))asstream:
55-
output=stream.read()
56-
assertnotre.search('Tralalala',output)
57-
assertre.search('ideetje',output)
58-
assertre.search('Jakkamakka',output)
59-
withopen(os.path.join(app.outdir,"key.html"))asstream:
60-
output=stream.read()
61-
assertnotre.search('Tralalala',output)
62-
assertre.search('ideetje',output)
63-
assertnotre.search('Jakkamakka',output)
64-
withopen(os.path.join(app.outdir,"false.html"))asstream:
65-
output=stream.read()
66-
assertnotre.search('Tralalala',output)
67-
assertnotre.search('ideetje',output)
68-
assertnotre.search('Jakkamakka',output)
69-
withopen(os.path.join(app.outdir,"title.html"))asstream:
70-
output=stream.read()
71-
assertnotre.search('Tralalala',output)
72-
assertnotre.search('ideetje',output)
73-
assertre.search('Jakkamakka',output)
23+
output= (app.outdir/"contents.html").read_text()
24+
assertre.search('Tralalala',output)
25+
assertnotre.search('ideetje',output)
26+
assertnotre.search('Jakkamakka',output)
27+
output= (app.outdir/"or.html").read_text()
28+
assertnotre.search('Tralalala',output)
29+
assertre.search('ideetje',output)
30+
assertre.search('Jakkamakka',output)
31+
output= (app.outdir/"noteq.html").read_text()
32+
assertre.search('Tralalala',output)
33+
assertre.search('ideetje',output)
34+
assertnotre.search('Jakkamakka',output)
35+
output= (app.outdir/"lt.html").read_text()
36+
assertre.search('Tralalala',output)
37+
assertnotre.search('ideetje',output)
38+
assertnotre.search('Jakkamakka',output)
39+
output= (app.outdir/"lte.html").read_text()
40+
assertre.search('Tralalala',output)
41+
assertnotre.search('ideetje',output)
42+
assertre.search('Jakkamakka',output)
43+
output= (app.outdir/"gt.html").read_text()
44+
assertnotre.search('Tralalala',output)
45+
assertre.search('ideetje',output)
46+
assertnotre.search('Jakkamakka',output)
47+
output= (app.outdir/"gte.html").read_text()
48+
assertnotre.search('Tralalala',output)
49+
assertre.search('ideetje',output)
50+
assertre.search('Jakkamakka',output)
51+
output= (app.outdir/"key.html").read_text()
52+
assertnotre.search('Tralalala',output)
53+
assertre.search('ideetje',output)
54+
assertnotre.search('Jakkamakka',output)
55+
output= (app.outdir/"false.html").read_text()
56+
assertnotre.search('Tralalala',output)
57+
assertnotre.search('ideetje',output)
58+
assertnotre.search('Jakkamakka',output)
59+
output= (app.outdir/"title.html").read_text()
60+
assertnotre.search('Tralalala',output)
61+
assertnotre.search('ideetje',output)
62+
assertre.search('Jakkamakka',output)

‎test/test_issue14.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test duplicate label issue.
77
"""
88

9-
importos.path
109
importre
1110
fromsphinx_testing.utilimportpath,with_app
1211

@@ -24,7 +23,7 @@ def test_duplicate_label(app, status, warning):
2423
assertre.search(
2524
'duplicate label for keys (Test and Test2)|(Test2 and Test)',
2625
warning.getvalue())
27-
withopen(os.path.join(app.outdir,"doc1.html"))asstream:
28-
assertre.search('<td>\\[1\\]</td>',stream.read())
29-
withopen(os.path.join(app.outdir,"doc2.html"))asstream:
30-
assertre.search('<td>\\[1\\]</td>',stream.read())
26+
output= (app.outdir/"doc1.html").read_text()
27+
assertre.search('<td>\\[1\\]</td>',output)
28+
output= (app.outdir/"doc2.html").read_text()
29+
assertre.search('<td>\\[1\\]</td>',output)

‎test/test_issue14_2.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test labelprefix option.
77
"""
88

9-
importos.path
109
importre
1110

1211
fromsphinx_testing.utilimportpath,with_app
@@ -21,7 +20,7 @@ def teardown_module():
2120
@with_app(srcdir=srcdir,warningiserror=True)
2221
deftest_label_prefix(app,status,warning):
2322
app.builder.build_all()
24-
withopen(os.path.join(app.outdir,"doc1.html"))asstream:
25-
assertre.search('<td>\\[A1\\]</td>',stream.read())
26-
withopen(os.path.join(app.outdir,"doc2.html"))asstream:
27-
assertre.search('<td>\\[B1\\]</td>',stream.read())
23+
output= (app.outdir/"doc1.html").read_text()
24+
assertre.search('<td>\\[A1\\]</td>',output)
25+
output= (app.outdir/"doc2.html").read_text()
26+
assertre.search('<td>\\[B1\\]</td>',output)

‎test/test_issue15.py‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test order of bibliography entries when using an unsorted style.
77
"""
88

9-
importos.path
109
importre
1110
fromsphinx_testing.utilimportpath,with_app
1211

@@ -21,7 +20,7 @@ def teardown_module():
2120
@with_app(srcdir=srcdir,warningiserror=True)
2221
deftest_duplicate_label(app,status,warning):
2322
app.builder.build_all()
24-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
25-
assertre.search(
26-
'<tr>.*Test 1.*</tr>.*<tr>.*Test 2.*</tr>',
27-
stream.read(),re.DOTALL)
23+
output= (app.outdir/"contents.html").read_text()
24+
assertre.search(
25+
'<tr>.*Test 1.*</tr>.*<tr>.*Test 2.*</tr>',
26+
output,re.DOTALL)

‎test/test_issue4.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test the ``:encoding:`` option.
77
"""
88

9-
importos.path
109
importre
1110

1211
fromsphinx_testing.utilimportpath,with_app
@@ -21,5 +20,5 @@ def teardown_module():
2120
@with_app(srcdir=srcdir,warningiserror=True)
2221
deftest_encoding(app,status,warning):
2322
app.builder.build_all()
24-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
25-
assertre.search("Tést☺",stream.read())
23+
output= (app.outdir/"contents.html").read_text()
24+
assertre.search("Tést☺",output)

‎test/test_issue61.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test multiple keys in a single cite.
77
"""
88

9-
importos
109
importre
1110
fromsphinx_testing.utilimportpath,with_app
1211

@@ -20,7 +19,6 @@ def teardown_module():
2019
@with_app(srcdir=srcdir,warningiserror=True)
2120
deftest_multiple_keys(app,status,warning):
2221
app.builder.build_all()
23-
withopen(os.path.join(app.outdir,"contents.html"))asstream:
24-
code=stream.read()
25-
assertre.search('class="reference internal" href="#testone"',code)
26-
assertre.search('class="reference internal" href="#testtwo"',code)
22+
output= (app.outdir/"contents.html").read_text()
23+
assertre.search('class="reference internal" href="#testone"',output)
24+
assertre.search('class="reference internal" href="#testtwo"',output)

‎test/test_issue62.py‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Test local bibliographies.
77
"""
88

9-
importos
109
importre
1110
fromsphinx_testing.utilimportpath,with_app
1211

@@ -74,12 +73,12 @@ def test_local_bibliographies(app, status, warning):
7473
'mcmahon-membrane-2010',
7574
])
7675
app.builder.build_all()
77-
withopen(os.path.join(app.outdir,"doc1.html"))asstream:
78-
check_code(stream.read(),doc1_refs,doc1_cites,
79-
doc2_refs|sum_refs,doc2_cites|sum_cites)
80-
withopen(os.path.join(app.outdir,"doc2.html"))asstream:
81-
check_code(stream.read(),doc2_refs,doc2_cites,
82-
doc1_refs|sum_refs,doc1_cites|sum_cites)
83-
withopen(os.path.join(app.outdir,"summary.html"))asstream:
84-
check_code(stream.read(),sum_refs,sum_cites,
85-
doc1_refs|doc2_refs,doc1_cites|doc2_cites)
76+
output= (app.outdir/"doc1.html").read_text()
77+
check_code(output,doc1_refs,doc1_cites,
78+
doc2_refs|sum_refs,doc2_cites|sum_cites)
79+
output= (app.outdir/"doc2.html").read_text()
80+
check_code(output,doc2_refs,doc2_cites,
81+
doc1_refs|sum_refs,doc1_cites|sum_cites)
82+
output= (app.outdir/"summary.html").read_text()
83+
check_code(output,sum_refs,sum_cites,
84+
doc1_refs|doc2_refs,doc1_cites|doc2_cites)

‎test/test_latex_refs.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Check that LaTeX backend produces correct references.
77
"""
88

9-
importos
109
importre
1110
fromsphinx_testing.utilimportpath,with_app
1211

@@ -20,7 +19,6 @@ def teardown_module():
2019
@with_app(srcdir=srcdir,warningiserror=True,buildername='latex')
2120
deftest_latex_refs(app,status,warning):
2221
app.builder.build_all()
23-
withopen(os.path.join(app.outdir,"test.tex"))asstream:
24-
code=stream.read()
25-
assertre.search('\\hyperref\[contents:huygens\]',code)
26-
assertre.search('\\label{contents:huygens}',code)
22+
output= (app.outdir/"test.tex").read_text()
23+
assertre.search('\\hyperref\[contents:huygens\]',output)
24+
assertre.search('\\label{contents:huygens}',output)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp