@@ -84,10 +84,10 @@ def test_basic(doctree, buildername):
84
84
tree = doctree (source , buildername = buildername )
85
85
(cell ,) = tree .traverse (JupyterCellNode )
86
86
(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" ]
91
91
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
92
92
assert celloutput .children [0 ].rawsource .strip () == "4"
93
93
@@ -101,10 +101,10 @@ def test_basic_old_entrypoint(doctree):
101
101
tree = doctree (source , entrypoint = "jupyter_sphinx.execute" )
102
102
(cell ,) = tree .traverse (JupyterCellNode )
103
103
(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" ]
108
108
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
109
109
assert celloutput .children [0 ].rawsource .strip () == "4"
110
110
@@ -119,7 +119,7 @@ def test_hide_output(doctree):
119
119
tree = doctree (source )
120
120
(cell ,) = tree .traverse (JupyterCellNode )
121
121
(cellinput , celloutput ) = cell .children
122
- assert cell .attributes ["hide_output" ] is True
122
+ assert cell .attributes ["hide_output" ]
123
123
assert len (celloutput .children ) == 0
124
124
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
125
125
@@ -134,7 +134,7 @@ def test_hide_code(doctree):
134
134
tree = doctree (source )
135
135
(cell ,) = tree .traverse (JupyterCellNode )
136
136
(celloutput ,) = cell .children
137
- assert cell .attributes ["hide_code" ] is True
137
+ assert cell .attributes ["hide_code" ]
138
138
assert len (cell .children ) == 1
139
139
assert celloutput .children [0 ].rawsource .strip () == "4"
140
140
@@ -149,7 +149,7 @@ def test_code_below(doctree):
149
149
tree = doctree (source )
150
150
(cell ,) = tree .traverse (JupyterCellNode )
151
151
(celloutput , cellinput ) = cell .children
152
- assert cell .attributes ["code_below" ] is True
152
+ assert cell .attributes ["code_below" ]
153
153
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
154
154
assert celloutput .children [0 ].rawsource .strip () == "4"
155
155
@@ -164,7 +164,7 @@ def test_linenos(doctree):
164
164
tree = doctree (source )
165
165
(cell ,) = tree .traverse (JupyterCellNode )
166
166
(cellinput , celloutput ) = cell .children
167
- assert cell . attributes [ "linenos" ] is True
167
+ assert cellinput . children [ 0 ][ "linenos" ]
168
168
assert len (cell .children ) == 2
169
169
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
170
170
assert celloutput .children [0 ].rawsource .strip () == "4"
@@ -177,9 +177,8 @@ def test_linenos(doctree):
177
177
"""
178
178
tree = doctree (source )
179
179
(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" ]
183
182
184
183
185
184
def test_linenos_conf_option (doctree ):
@@ -191,8 +190,8 @@ def test_linenos_conf_option(doctree):
191
190
tree = doctree (source , config = "jupyter_sphinx_linenos = True" )
192
191
(cell ,) = tree .traverse (JupyterCellNode )
193
192
(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
196
195
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
197
196
assert celloutput .children [0 ].rawsource .strip () == "4"
198
197
@@ -209,7 +208,7 @@ def test_continue_linenos_conf_option(doctree):
209
208
tree = doctree (source , config = "jupyter_sphinx_continue_linenos = True" )
210
209
(cell ,) = tree .traverse (JupyterCellNode )
211
210
(cellinput , celloutput ) = cell .children
212
- assert "linenos" not in cellinput .attributes
211
+ assert not cellinput .children [ 0 ]. attributes [ "linenos" ]
213
212
assert cellinput .children [0 ].rawsource .strip () == "2 + 2"
214
213
assert celloutput .children [0 ].rawsource .strip () == "4"
215
214
@@ -234,12 +233,12 @@ def test_continue_linenos_conf_option(doctree):
234
233
cell0 , cell1 = tree .traverse (JupyterCellNode )
235
234
(cellinput0 , celloutput0 ) = cell0 .children
236
235
(cellinput1 , celloutput1 ) = cell1 .children
237
- assert cellinput0 .attributes ["linenos" ]
236
+ assert cellinput0 .children [ 0 ]. attributes ["linenos" ]
238
237
assert cellinput0 .children [0 ].rawsource .strip () == "2 + 2"
239
238
assert celloutput0 .children [0 ].rawsource .strip () == "4"
240
239
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
243
242
assert cellinput1 .children [0 ].rawsource .strip () == "3 + 3"
244
243
assert celloutput1 .children [0 ].rawsource .strip () == "6"
245
244
@@ -264,12 +263,12 @@ def test_continue_linenos_conf_option(doctree):
264
263
cell0 , cell1 = tree .traverse (JupyterCellNode )
265
264
(cellinput0 , celloutput0 ) = cell0 .children
266
265
(cellinput1 , celloutput1 ) = cell1 .children
267
- assert cellinput0 .attributes ["highlight_args" ]["linenostart" ] == 7
266
+ assert cellinput0 .children [ 0 ]. attributes ["highlight_args" ]["linenostart" ] == 7
268
267
assert cellinput0 .children [0 ].rawsource .strip () == "2 + 2"
269
268
assert celloutput0 .children [0 ].rawsource .strip () == "4"
270
269
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
273
272
assert cellinput1 .children [0 ].rawsource .strip () == "3 + 3"
274
273
assert celloutput1 .children [0 ].rawsource .strip () == "6"
275
274
@@ -455,7 +454,7 @@ def test_thebe_hide_output(doctree):
455
454
tree = doctree (source , thebe_config )
456
455
(cell ,) = tree .traverse (JupyterCellNode )
457
456
(cellinput , celloutput ) = cell .children
458
- assert cell .attributes ["hide_output" ] is True
457
+ assert cell .attributes ["hide_output" ]
459
458
assert len (celloutput .children ) == 0
460
459
461
460
source = cellinput .children [0 ]
@@ -474,12 +473,12 @@ def test_thebe_hide_code(doctree):
474
473
tree = doctree (source , thebe_config )
475
474
(cell ,) = tree .traverse (JupyterCellNode )
476
475
(cellinput , celloutput ) = cell .children
477
- assert cell .attributes ["hide_code" ] is True
476
+ assert cell .attributes ["hide_code" ]
478
477
assert len (cell .children ) == 2
479
478
480
479
source = cellinput .children [0 ]
481
480
assert type (source ) == ThebeSourceNode
482
- assert source .attributes ["hide_code" ] is True
481
+ assert source .attributes ["hide_code" ]
483
482
assert len (source .children ) == 1
484
483
assert source .children [0 ].rawsource .strip () == "2 + 2"
485
484
@@ -499,7 +498,7 @@ def test_thebe_code_below(doctree):
499
498
tree = doctree (source , thebe_config )
500
499
(cell ,) = tree .traverse (JupyterCellNode )
501
500
(cellinput , celloutput ) = cell .children
502
- assert cell .attributes ["code_below" ] is True
501
+ assert cell .attributes ["code_below" ]
503
502
504
503
output = cellinput .children [0 ]
505
504
assert type (output ) is ThebeOutputNode
@@ -510,7 +509,7 @@ def test_thebe_code_below(doctree):
510
509
assert type (source ) is ThebeSourceNode
511
510
assert len (source .children ) == 1
512
511
assert source .children [0 ].rawsource .strip () == "2 + 2"
513
- assert source .attributes ["code_below" ] is True
512
+ assert source .attributes ["code_below" ]
514
513
515
514
516
515
def test_thebe_button_auto (doctree ):
0 commit comments