@@ -84,10 +84,10 @@ def test_basic(doctree, buildername):
8484 tree = doctree (source , buildername = buildername )
8585 (cell ,) = tree .traverse (JupyterCellNode )
8686 (cellinput , celloutput ) = cell .children
87- assert cell .attributes ["code_below" ] is False
88- assert cell .attributes ["hide_code" ] is False
89- assert cell .attributes ["hide_output" ] is False
90- assert cell . attributes [ "linenos" ] is False
87+ assert not cell .attributes ["code_below" ]
88+ assert not cell .attributes ["hide_code" ]
89+ assert not cell .attributes ["hide_output" ]
90+ assert not cellinput . children [ 0 ][ "linenos" ]
9191 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
9292 assert celloutput .children [0 ].rawsource .strip () == "4"
9393
@@ -101,10 +101,10 @@ def test_basic_old_entrypoint(doctree):
101101 tree = doctree (source , entrypoint = "jupyter_sphinx.execute" )
102102 (cell ,) = tree .traverse (JupyterCellNode )
103103 (cellinput , celloutput ) = cell .children
104- assert cell .attributes ["code_below" ] is False
105- assert cell .attributes ["hide_code" ] is False
106- assert cell .attributes ["hide_output" ] is False
107- assert cell . attributes [ "linenos" ] is False
104+ assert not cell .attributes ["code_below" ]
105+ assert not cell .attributes ["hide_code" ]
106+ assert not cell .attributes ["hide_output" ]
107+ assert not cellinput . children [ 0 ][ "linenos" ]
108108 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
109109 assert celloutput .children [0 ].rawsource .strip () == "4"
110110
@@ -119,7 +119,7 @@ def test_hide_output(doctree):
119119 tree = doctree (source )
120120 (cell ,) = tree .traverse (JupyterCellNode )
121121 (cellinput , celloutput ) = cell .children
122- assert cell .attributes ["hide_output" ] is True
122+ assert cell .attributes ["hide_output" ]
123123 assert len (celloutput .children ) == 0
124124 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
125125
@@ -134,7 +134,7 @@ def test_hide_code(doctree):
134134 tree = doctree (source )
135135 (cell ,) = tree .traverse (JupyterCellNode )
136136 (celloutput ,) = cell .children
137- assert cell .attributes ["hide_code" ] is True
137+ assert cell .attributes ["hide_code" ]
138138 assert len (cell .children ) == 1
139139 assert celloutput .children [0 ].rawsource .strip () == "4"
140140
@@ -149,7 +149,7 @@ def test_code_below(doctree):
149149 tree = doctree (source )
150150 (cell ,) = tree .traverse (JupyterCellNode )
151151 (celloutput , cellinput ) = cell .children
152- assert cell .attributes ["code_below" ] is True
152+ assert cell .attributes ["code_below" ]
153153 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
154154 assert celloutput .children [0 ].rawsource .strip () == "4"
155155
@@ -164,7 +164,7 @@ def test_linenos(doctree):
164164 tree = doctree (source )
165165 (cell ,) = tree .traverse (JupyterCellNode )
166166 (cellinput , celloutput ) = cell .children
167- assert cell . attributes [ "linenos" ] is True
167+ assert cellinput . children [ 0 ][ "linenos" ]
168168 assert len (cell .children ) == 2
169169 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
170170 assert celloutput .children [0 ].rawsource .strip () == "4"
@@ -177,9 +177,8 @@ def test_linenos(doctree):
177177 """
178178 tree = doctree (source )
179179 (cell ,) = tree .traverse (JupyterCellNode )
180- (cellinput , celloutput ) = cell .children
181- assert len (cell .children ) == 2
182- assert cell .attributes ["linenos" ] is True
180+ (celloutput , cellinput ) = cell .children
181+ assert cellinput .children [0 ]["linenos" ]
183182
184183
185184def test_linenos_conf_option (doctree ):
@@ -191,8 +190,8 @@ def test_linenos_conf_option(doctree):
191190 tree = doctree (source , config = "jupyter_sphinx_linenos = True" )
192191 (cell ,) = tree .traverse (JupyterCellNode )
193192 (cellinput , celloutput ) = cell .children
194- assert cellinput .attributes ["linenos" ]
195- assert "highlight_args" not in cellinput .attributes
193+ assert cellinput .children [ 0 ]. attributes ["linenos" ]
194+ assert "highlight_args" not in cellinput .children [ 0 ]. attributes
196195 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
197196 assert celloutput .children [0 ].rawsource .strip () == "4"
198197
@@ -209,7 +208,7 @@ def test_continue_linenos_conf_option(doctree):
209208 tree = doctree (source , config = "jupyter_sphinx_continue_linenos = True" )
210209 (cell ,) = tree .traverse (JupyterCellNode )
211210 (cellinput , celloutput ) = cell .children
212- assert "linenos" not in cellinput .attributes
211+ assert not cellinput .children [ 0 ]. attributes [ "linenos" ]
213212 assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
214213 assert celloutput .children [0 ].rawsource .strip () == "4"
215214
@@ -234,12 +233,12 @@ def test_continue_linenos_conf_option(doctree):
234233 cell0 , cell1 = tree .traverse (JupyterCellNode )
235234 (cellinput0 , celloutput0 ) = cell0 .children
236235 (cellinput1 , celloutput1 ) = cell1 .children
237- assert cellinput0 .attributes ["linenos" ]
236+ assert cellinput0 .children [ 0 ]. attributes ["linenos" ]
238237 assert cellinput0 .children [0 ].rawsource .strip () == "2 + 2"
239238 assert celloutput0 .children [0 ].rawsource .strip () == "4"
240239
241- assert cellinput1 .attributes ["linenos" ]
242- assert cellinput1 .attributes ["highlight_args" ]["linenostart" ] == 2
240+ assert cellinput1 .children [ 0 ]. attributes ["linenos" ]
241+ assert cellinput1 .children [ 0 ]. attributes ["highlight_args" ]["linenostart" ] == 2
243242 assert cellinput1 .children [0 ].rawsource .strip () == "3 + 3"
244243 assert celloutput1 .children [0 ].rawsource .strip () == "6"
245244
@@ -264,12 +263,12 @@ def test_continue_linenos_conf_option(doctree):
264263 cell0 , cell1 = tree .traverse (JupyterCellNode )
265264 (cellinput0 , celloutput0 ) = cell0 .children
266265 (cellinput1 , celloutput1 ) = cell1 .children
267- assert cellinput0 .attributes ["highlight_args" ]["linenostart" ] == 7
266+ assert cellinput0 .children [ 0 ]. attributes ["highlight_args" ]["linenostart" ] == 7
268267 assert cellinput0 .children [0 ].rawsource .strip () == "2 + 2"
269268 assert celloutput0 .children [0 ].rawsource .strip () == "4"
270269
271- assert cellinput1 .attributes ["linenos" ]
272- assert cellinput1 .attributes ["highlight_args" ]["linenostart" ] == 8
270+ assert cellinput1 .children [ 0 ]. attributes ["linenos" ]
271+ assert cellinput1 .children [ 0 ]. attributes ["highlight_args" ]["linenostart" ] == 8
273272 assert cellinput1 .children [0 ].rawsource .strip () == "3 + 3"
274273 assert celloutput1 .children [0 ].rawsource .strip () == "6"
275274
@@ -455,7 +454,7 @@ def test_thebe_hide_output(doctree):
455454 tree = doctree (source , thebe_config )
456455 (cell ,) = tree .traverse (JupyterCellNode )
457456 (cellinput , celloutput ) = cell .children
458- assert cell .attributes ["hide_output" ] is True
457+ assert cell .attributes ["hide_output" ]
459458 assert len (celloutput .children ) == 0
460459
461460 source = cellinput .children [0 ]
@@ -474,12 +473,12 @@ def test_thebe_hide_code(doctree):
474473 tree = doctree (source , thebe_config )
475474 (cell ,) = tree .traverse (JupyterCellNode )
476475 (cellinput , celloutput ) = cell .children
477- assert cell .attributes ["hide_code" ] is True
476+ assert cell .attributes ["hide_code" ]
478477 assert len (cell .children ) == 2
479478
480479 source = cellinput .children [0 ]
481480 assert type (source ) == ThebeSourceNode
482- assert source .attributes ["hide_code" ] is True
481+ assert source .attributes ["hide_code" ]
483482 assert len (source .children ) == 1
484483 assert source .children [0 ].rawsource .strip () == "2 + 2"
485484
@@ -499,7 +498,7 @@ def test_thebe_code_below(doctree):
499498 tree = doctree (source , thebe_config )
500499 (cell ,) = tree .traverse (JupyterCellNode )
501500 (cellinput , celloutput ) = cell .children
502- assert cell .attributes ["code_below" ] is True
501+ assert cell .attributes ["code_below" ]
503502
504503 output = cellinput .children [0 ]
505504 assert type (output ) is ThebeOutputNode
@@ -510,7 +509,7 @@ def test_thebe_code_below(doctree):
510509 assert type (source ) is ThebeSourceNode
511510 assert len (source .children ) == 1
512511 assert source .children [0 ].rawsource .strip () == "2 + 2"
513- assert source .attributes ["code_below" ] is True
512+ assert source .attributes ["code_below" ]
514513
515514
516515def test_thebe_button_auto (doctree ):
0 commit comments