@@ -26,7 +26,7 @@ def doctree():
26
26
apps = []
27
27
syspath = sys .path [:]
28
28
29
- def doctree (source , config = None ):
29
+ def doctree (source , config = None , return_warnings = False ):
30
30
src_dir = tempfile .mkdtemp ()
31
31
source_trees .append (src_dir )
32
32
with open (os .path .join (src_dir , 'conf.py' ), 'w' ) as f :
@@ -35,11 +35,18 @@ def doctree(source, config=None):
35
35
f .write ('\n ' + config )
36
36
with open (os .path .join (src_dir , 'index.rst' ), 'w' ) as f :
37
37
f .write (source )
38
+ warnings = StringIO ()
38
39
app = SphinxTestApp (srcdir = path (src_dir ), status = StringIO (),
39
- warning = StringIO () )
40
+ warning = warnings )
40
41
apps .append (app )
41
42
app .build ()
42
- return app .env .get_doctree ('index' )
43
+
44
+ doctree = app .env .get_doctree ("index" )
45
+
46
+ if return_warnings :
47
+ return doctree , warnings .getvalue ()
48
+ else :
49
+ return doctree
43
50
44
51
yield doctree
45
52
@@ -217,8 +224,11 @@ def test_stderr(doctree):
217
224
import sys
218
225
print('hello world', file=sys.stderr)
219
226
"""
220
- with pytest .raises (ExtensionError ):
221
- tree = doctree (source )
227
+
228
+ tree , warnings = doctree (source , return_warnings = True )
229
+ assert "hello world" in warnings
230
+ cell , = tree .traverse (JupyterCellNode )
231
+ assert len (cell .children ) == 1 # no output
222
232
223
233
source = """
224
234
.. jupyter-execute::
0 commit comments