Skip to content

Commit d16913a

Browse files
fix formatting issues
1 parent e1bc3de commit d16913a

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

test/integ_tests/test_all_notebooks.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import os
3-
from importlib.machinery import SourceFileLoader
43
import re
4+
from importlib.machinery import SourceFileLoader
55

66
import pytest
77
from jupyter_client import kernelspec
@@ -164,7 +164,7 @@ def check_cells_for_error_output(cells):
164164
if output["output_type"] == "error":
165165
pytest.fail("Found error output in cell: " + str(output))
166166

167-
167+
168168
def execute_with_mocks(tb, mock_level, path_to_utils, path_to_mocks):
169169
# We do this check to make sure that the notebook can be executed (with mocks).
170170
tb.inject(
@@ -178,7 +178,7 @@ def execute_with_mocks(tb, mock_level, path_to_utils, path_to_mocks):
178178
run=False,
179179
before=0,
180180
)
181-
181+
182182
# Uncomment all test sections in the notebook
183183
for i, cell in enumerate(tb.cells):
184184
if cell.get("cell_type") == "code" and "source" in cell:
@@ -187,39 +187,37 @@ def execute_with_mocks(tb, mock_level, path_to_utils, path_to_mocks):
187187
# Uncomment the test section
188188
modified_source = uncomment_test_section(source)
189189
tb.cells[i]["source"] = modified_source
190-
190+
191191
# Execute the notebook with the uncommented test sections
192192
tb.execute()
193193
test_mocks = SourceFileLoader("notebook_mocks", path_to_mocks).load_module()
194194
test_mocks.post_run(tb)
195195

196-
197196

198197
def uncomment_test_section(source):
199198
"""Uncomment sections marked with # UNCOMMENT_TO_RUN."""
200-
descriptive_comment = re.compile(r'^\s*##\s')
201-
regular_comment = re.compile(r'^\s*#\s?')
202-
203-
199+
descriptive_comment = re.compile(r"^\s*##\s")
200+
regular_comment = re.compile(r"^\s*#\s?")
201+
204202
lines = source.splitlines()
205203
result = []
206204
uncomment_mode = False
207-
205+
208206
for line in lines:
209207
stripped_line = line.strip()
210-
208+
211209
if stripped_line == "# UNCOMMENT_FOR_TEST":
212210
uncomment_mode = True
213211
result.append(line)
214212
continue
215-
213+
216214
if uncomment_mode:
217215
if descriptive_comment.match(stripped_line):
218216
# Handle descriptive comments (##)
219217
result.append(f"# {stripped_line[3:].lstrip()}")
220218
elif regular_comment.match(stripped_line):
221219
# Handle regular comments (#)
222-
result.append(regular_comment.sub('', line))
220+
result.append(regular_comment.sub("", line))
223221
elif stripped_line:
224222
# Non-empty, non-comment line
225223
uncomment_mode = False
@@ -229,5 +227,5 @@ def uncomment_test_section(source):
229227
result.append(line)
230228
else:
231229
result.append(line)
232-
233-
return '\n'.join(result)
230+
231+
return "\n".join(result)

0 commit comments

Comments
 (0)