@@ -31,67 +31,76 @@ def nonascii_srcdir(request, rootdir, sphinx_test_tempdir):
3131 shutil .copytree (rootdir / 'test-root' , srcdir )
3232
3333 # add a doc with a non-ASCII file name to the source dir
34- (srcdir / (test_name + '.txt' )).write_text ("""
34+ (srcdir / (test_name + '.txt' )).write_text (
35+ """
3536nonascii file name page
3637=======================
37- """ , encoding = 'utf8' )
38+ """ ,
39+ encoding = 'utf8' ,
40+ )
3841
3942 root_doc = srcdir / 'index.txt'
40- root_doc .write_text (root_doc .read_text (encoding = 'utf8' ) + f"""
43+ root_doc .write_text (
44+ root_doc .read_text (encoding = 'utf8' )
45+ + f"""
4146.. toctree::
4247
4348{ test_name } /{ test_name }
44- """ , encoding = 'utf8' )
49+ """ ,
50+ encoding = 'utf8' ,
51+ )
4552 return srcdir
4653
4754
4855# note: this test skips building docs for some builders because they have independent testcase.
4956# (html, changes, epub, latex, texinfo and manpage)
5057@pytest .mark .parametrize (
51- " buildername" ,
58+ ' buildername' ,
5259 ['dirhtml' , 'singlehtml' , 'text' , 'xml' , 'pseudoxml' , 'linkcheck' ],
5360)
54- @mock .patch ('sphinx.builders.linkcheck.requests.head' ,
55- side_effect = request_session_head )
61+ @mock .patch (
62+ 'sphinx.builders.linkcheck.requests.head' ,
63+ side_effect = request_session_head ,
64+ )
5665def test_build_all (requests_head , make_app , nonascii_srcdir , buildername ):
5766 app = make_app (buildername , srcdir = nonascii_srcdir )
5867 app .build ()
5968
6069
6170def test_root_doc_not_found (tmp_path , make_app ):
62- (tmp_path / 'conf.py' ).write_text ( '' , encoding = 'utf8' )
71+ (tmp_path / 'conf.py' ).touch ( )
6372 assert os .listdir (tmp_path ) == ['conf.py' ]
6473
6574 app = make_app ('dummy' , srcdir = tmp_path )
6675 with pytest .raises (SphinxError ):
6776 app .build (force_all = True ) # no index.rst
6877
6978
70- @pytest .mark .sphinx (buildername = 'text' , testroot = 'circular' )
79+ @pytest .mark .sphinx ('text' , testroot = 'circular' )
7180def test_circular_toctree (app ):
7281 app .build (force_all = True )
7382 warnings = app .warning .getvalue ()
7483 assert (
75- 'circular toctree references detected, ignoring: '
76- 'sub <- index <- sub' ) in warnings
84+ 'circular toctree references detected, ignoring: sub <- index <- sub '
85+ ) in warnings
7786 assert (
78- 'circular toctree references detected, ignoring: '
79- 'index <- sub <- index' ) in warnings
87+ 'circular toctree references detected, ignoring: index <- sub <- index '
88+ ) in warnings
8089
8190
82- @pytest .mark .sphinx (buildername = 'text' , testroot = 'numbered-circular' )
91+ @pytest .mark .sphinx ('text' , testroot = 'numbered-circular' )
8392def test_numbered_circular_toctree (app ):
8493 app .build (force_all = True )
8594 warnings = app .warning .getvalue ()
8695 assert (
87- 'circular toctree references detected, ignoring: '
88- 'sub <- index <- sub' ) in warnings
96+ 'circular toctree references detected, ignoring: sub <- index <- sub '
97+ ) in warnings
8998 assert (
90- 'circular toctree references detected, ignoring: '
91- 'index <- sub <- index' ) in warnings
99+ 'circular toctree references detected, ignoring: index <- sub <- index '
100+ ) in warnings
92101
93102
94- @pytest .mark .sphinx (buildername = 'dummy' , testroot = 'images' )
103+ @pytest .mark .sphinx ('dummy' , testroot = 'images' )
95104def test_image_glob (app ):
96105 app .build (force_all = True )
97106
@@ -108,16 +117,20 @@ def test_image_glob(app):
108117 assert doctree [0 ][2 ][0 ]['uri' ] == 'rimg.png'
109118
110119 assert isinstance (doctree [0 ][3 ], nodes .image )
111- assert doctree [0 ][3 ]['candidates' ] == {'application/pdf' : 'img.pdf' ,
112- 'image/gif' : 'img.gif' ,
113- 'image/png' : 'img.png' }
120+ assert doctree [0 ][3 ]['candidates' ] == {
121+ 'application/pdf' : 'img.pdf' ,
122+ 'image/gif' : 'img.gif' ,
123+ 'image/png' : 'img.png' ,
124+ }
114125 assert doctree [0 ][3 ]['uri' ] == 'img.*'
115126
116127 assert isinstance (doctree [0 ][4 ], nodes .figure )
117128 assert isinstance (doctree [0 ][4 ][0 ], nodes .image )
118- assert doctree [0 ][4 ][0 ]['candidates' ] == {'application/pdf' : 'img.pdf' ,
119- 'image/gif' : 'img.gif' ,
120- 'image/png' : 'img.png' }
129+ assert doctree [0 ][4 ][0 ]['candidates' ] == {
130+ 'application/pdf' : 'img.pdf' ,
131+ 'image/gif' : 'img.gif' ,
132+ 'image/png' : 'img.png' ,
133+ }
121134 assert doctree [0 ][4 ][0 ]['uri' ] == 'img.*'
122135
123136 # subdir/index.rst
@@ -128,14 +141,18 @@ def test_image_glob(app):
128141 assert doctree [0 ][1 ]['uri' ] == 'subdir/rimg.png'
129142
130143 assert isinstance (doctree [0 ][2 ], nodes .image )
131- assert doctree [0 ][2 ]['candidates' ] == {'application/pdf' : 'subdir/svgimg.pdf' ,
132- 'image/svg+xml' : 'subdir/svgimg.svg' }
144+ assert doctree [0 ][2 ]['candidates' ] == {
145+ 'application/pdf' : 'subdir/svgimg.pdf' ,
146+ 'image/svg+xml' : 'subdir/svgimg.svg' ,
147+ }
133148 assert doctree [0 ][2 ]['uri' ] == 'subdir/svgimg.*'
134149
135150 assert isinstance (doctree [0 ][3 ], nodes .figure )
136151 assert isinstance (doctree [0 ][3 ][0 ], nodes .image )
137- assert doctree [0 ][3 ][0 ]['candidates' ] == {'application/pdf' : 'subdir/svgimg.pdf' ,
138- 'image/svg+xml' : 'subdir/svgimg.svg' }
152+ assert doctree [0 ][3 ][0 ]['candidates' ] == {
153+ 'application/pdf' : 'subdir/svgimg.pdf' ,
154+ 'image/svg+xml' : 'subdir/svgimg.svg' ,
155+ }
139156 assert doctree [0 ][3 ][0 ]['uri' ] == 'subdir/svgimg.*'
140157
141158
0 commit comments