Debian Codegraph @

core/tests/integration_tests/runner_test.py

raw symbols SCIP
1 """Integration test for the main runner."""
2
3 from __future__ import annotations
4
5 import io
6 import pathlib
7 import re
8 import sys
9
10 import pytest
11
12 from rstcheck_core import _extras, config, runner
13 from tests.conftest import EXAMPLES_DIR
14 from tests.integration_tests.conftest import ERROR_CODE_REGEX
15
16
17 class TestInput:
18 """Test file input with good and bad files and piping."""
19
20 @staticmethod
21 @pytest.mark.parametrize("test_file", list(EXAMPLES_DIR.glob("good/*.rst")))
22 def test_all_good_examples(test_file: pathlib.Path, capsys: pytest.CaptureFixture[str]) -> None:
23 """Test all files in ``testing/examples/good`` are errorless."""
24 if sys.platform == "win32" and test_file.name == "bom.rst":
25 pytest.xfail(reason="BOM test fails for windows")
26 init_config = config.RstcheckConfig()
27 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
28
29 result = _runner.run()
30
31 assert result == 0
32 assert "Success! No issues detected." in capsys.readouterr().out
33
34 @staticmethod
35 @pytest.mark.xfail(
36 sys.platform == "win32", reason="Random unknown Windows specific wrong result", strict=False
37 )
38 def test_all_good_examples_recurively(capsys: pytest.CaptureFixture[str]) -> None:
39 """Test all files in ``testing/examples/good`` recursively."""
40 test_dir = EXAMPLES_DIR / "good"
41 init_config = config.RstcheckConfig(recursive=True)
42 _runner = runner.RstcheckMainRunner(check_paths=[test_dir], rstcheck_config=init_config)
43
44 result = _runner.run()
45
46 assert result == 0
47 assert "Success! No issues detected." in capsys.readouterr().out
48
49 @staticmethod
50 @pytest.mark.parametrize("test_file", list(EXAMPLES_DIR.glob("bad/*.rst")))
51 def test_all_bad_examples(test_file: pathlib.Path, capsys: pytest.CaptureFixture[str]) -> None:
52 """Test all files in ``testing/examples/bad`` have errors."""
53 if sys.platform == "win32" and test_file.name == "bash.rst":
54 pytest.xfail(reason="Unknown Windows specific wrong result for bash.rst")
55 init_config = config.RstcheckConfig()
56 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
57
58 result = _runner.run()
59
60 assert result != 0
61 assert ERROR_CODE_REGEX.search(capsys.readouterr().err) is not None
62
63 @staticmethod
64 def test_all_bad_examples_recurively(capsys: pytest.CaptureFixture[str]) -> None:
65 """Test all files in ``testing/examples/bad`` recursively."""
66 test_dir = EXAMPLES_DIR / "bad"
67 init_config = config.RstcheckConfig(recursive=True)
68 _runner = runner.RstcheckMainRunner(check_paths=[test_dir], rstcheck_config=init_config)
69
70 result = _runner.run()
71
72 assert result != 0
73 assert ERROR_CODE_REGEX.search(capsys.readouterr().err) is not None
74
75 @staticmethod
76 def test_mix_of_good_and_bad_examples(capsys: pytest.CaptureFixture[str]) -> None:
77 """Test mix of good and bad examples."""
78 test_file_good = EXAMPLES_DIR / "good" / "rst.rst"
79 test_file_bad = EXAMPLES_DIR / "bad" / "rst.rst"
80 init_config = config.RstcheckConfig()
81 _runner = runner.RstcheckMainRunner(
82 check_paths=[test_file_good, test_file_bad], rstcheck_config=init_config
83 )
84
85 result = _runner.run()
86
87 assert result != 0
88 assert ERROR_CODE_REGEX.search(capsys.readouterr().err) is not None
89
90 @staticmethod
91 def test_good_example_with_piping(
92 monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
93 ) -> None:
94 """Test good example file piped into rstcheck."""
95 test_file_pipe = EXAMPLES_DIR / "good" / "rst.rst"
96 test_file_pipe_content = test_file_pipe.read_text("utf-8")
97 monkeypatch.setattr(sys, "stdin", io.StringIO(test_file_pipe_content))
98 init_config = config.RstcheckConfig()
99 _runner = runner.RstcheckMainRunner(
100 check_paths=[pathlib.Path("-")], rstcheck_config=init_config
101 )
102
103 result = _runner.run()
104
105 assert result == 0
106 assert "Success! No issues detected." in capsys.readouterr().out
107
108 @staticmethod
109 def test_bad_example_with_piping(
110 monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
111 ) -> None:
112 """Test bad example file piped into rstcheck."""
113 test_file_pipe = EXAMPLES_DIR / "bad" / "rst.rst"
114 test_file_pipe_content = test_file_pipe.read_text("utf-8")
115 monkeypatch.setattr(sys, "stdin", io.StringIO(test_file_pipe_content))
116 init_config = config.RstcheckConfig()
117 _runner = runner.RstcheckMainRunner(
118 check_paths=[pathlib.Path("-")], rstcheck_config=init_config
119 )
120
121 result = _runner.run()
122
123 assert result != 0
124 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 1
125
126 @staticmethod
127 def test_piping_with_additional_files_results_in_nonexisting_file(
128 monkeypatch: pytest.MonkeyPatch,
129 capsys: pytest.CaptureFixture[str],
130 caplog: pytest.LogCaptureFixture,
131 ) -> None:
132 """Test piping into rstcheck is ignored with additional files."""
133 test_file = EXAMPLES_DIR / "good" / "rst.rst"
134 test_file_pipe = EXAMPLES_DIR / "bad" / "rst.rst"
135 test_file_pipe_content = test_file_pipe.read_text("utf-8")
136 monkeypatch.setattr(sys, "stdin", io.StringIO(test_file_pipe_content))
137 init_config = config.RstcheckConfig()
138 _runner = runner.RstcheckMainRunner(
139 check_paths=[pathlib.Path("-"), test_file], rstcheck_config=init_config
140 )
141
142 result = _runner.run()
143
144 assert result != 0
145 assert "Error! Issues detected." in capsys.readouterr().err
146 assert "Path does not exist or is not a file: '-'." in caplog.text
147
148
149 class TestIgnoreOptions:
150 """Test ignore_* options and report_level."""
151
152 @staticmethod
153 def test_without_report_exits_zero(capsys: pytest.CaptureFixture[str]) -> None:
154 """Test bad example without report is ok."""
155 test_file = EXAMPLES_DIR / "bad" / "rst.rst"
156 init_config = config.RstcheckConfig(report_level="none")
157 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
158
159 result = _runner.run()
160
161 assert result == 0
162 assert "Success! No issues detected." in capsys.readouterr().out
163
164 @staticmethod
165 def test_ignore_language_silences_error(capsys: pytest.CaptureFixture[str]) -> None:
166 """Test bad example with ignored language is ok."""
167 test_file = EXAMPLES_DIR / "bad" / "cpp.rst"
168 init_config = config.RstcheckConfig(ignore_languages="cpp")
169 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
170
171 result = _runner.run()
172
173 assert result == 0
174 assert "Success! No issues detected." in capsys.readouterr().out
175
176 @staticmethod
177 def test_matching_ignore_msg_exits_zero(capsys: pytest.CaptureFixture[str]) -> None:
178 """Test matching ignore message."""
179 test_file = EXAMPLES_DIR / "bad" / "rst.rst"
180 init_config = config.RstcheckConfig(
181 ignore_messages=r"(Title .verline & underline mismatch\.$)"
182 )
183 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
184
185 result = _runner.run()
186
187 assert result == 0
188 assert "Success! No issues detected." in capsys.readouterr().out
189
190 @staticmethod
191 def test_non_matching_ignore_msg_errors(capsys: pytest.CaptureFixture[str]) -> None:
192 """Test non matching ignore message."""
193 test_file = EXAMPLES_DIR / "bad" / "rst.rst"
194 init_config = config.RstcheckConfig(ignore_messages=r"(No match\.$)")
195 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
196
197 result = _runner.run()
198
199 assert result != 0
200 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 1
201
202 @staticmethod
203 def test_table_substitution_error_fixed_by_ignore(capsys: pytest.CaptureFixture[str]) -> None:
204 """Test that ignored substitutions in tables are correctly handled."""
205 test_file = EXAMPLES_DIR / "bad" / "table_substitutions.rst"
206 init_config = config.RstcheckConfig(ignore_substitutions="FOO_ID,BAR_ID")
207 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
208
209 result = _runner.run()
210
211 assert result == 0
212 assert "Success! No issues detected." in capsys.readouterr().out
213
214
215 class TestWithoutConfigFile:
216 """Test without config file in dir tree."""
217
218 @staticmethod
219 def test_error_without_config_file(capsys: pytest.CaptureFixture[str]) -> None:
220 """Test bad example without set config file and implicit config file shows errors."""
221 test_file = EXAMPLES_DIR / "without_configuration" / "bad.rst"
222 init_config = config.RstcheckConfig()
223 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
224
225 result = _runner.run()
226
227 assert result != 0
228 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 6
229
230 @staticmethod
231 def test_no_error_with_set_ini_config_file(capsys: pytest.CaptureFixture[str]) -> None:
232 """Test bad example with set INI config file does not error."""
233 test_file = EXAMPLES_DIR / "without_configuration" / "bad.rst"
234 config_file = EXAMPLES_DIR / "with_configuration" / "rstcheck.ini"
235 init_config = config.RstcheckConfig(config_path=config_file)
236 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
237
238 result = _runner.run()
239
240 assert result == 0
241 assert "Success! No issues detected." in capsys.readouterr().out
242
243 @staticmethod
244 def test_no_error_with_set_config_dir(capsys: pytest.CaptureFixture[str]) -> None:
245 """Test bad example with set config dir does not error."""
246 test_file = EXAMPLES_DIR / "without_configuration" / "bad.rst"
247 config_dir = EXAMPLES_DIR / "with_configuration"
248 init_config = config.RstcheckConfig(config_path=config_dir)
249 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
250
251 result = _runner.run()
252
253 assert result == 0
254 assert "Success! No issues detected." in capsys.readouterr().out
255
256 @staticmethod
257 @pytest.mark.skipif(not _extras.TOMLI_INSTALLED, reason="Depends on toml extra.")
258 def test_no_error_with_set_toml_config_file(capsys: pytest.CaptureFixture[str]) -> None:
259 """Test bad example with set TOML config file does not error."""
260 test_file = EXAMPLES_DIR / "without_configuration" / "bad.rst"
261 config_file = EXAMPLES_DIR / "with_configuration" / "pyproject.toml"
262 init_config = config.RstcheckConfig(config_path=config_file)
263 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
264
265 result = _runner.run()
266
267 assert result == 0
268 assert "Success! No issues detected." in capsys.readouterr().out
269
270
271 class TestWithConfigFile:
272 """Test with config file in dir tree."""
273
274 @staticmethod
275 def test_file_1_is_bad_without_config(capsys: pytest.CaptureFixture[str]) -> None:
276 """Test bad file ``bad.rst`` without config file is not ok."""
277 test_file = EXAMPLES_DIR / "with_configuration" / "bad.rst"
278 config_file = pathlib.Path("NONE")
279 init_config = config.RstcheckConfig(config_path=config_file)
280 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
281
282 result = _runner.run()
283
284 assert result != 0
285 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 6
286
287 @staticmethod
288 def test_file_2_is_bad_without_config(capsys: pytest.CaptureFixture[str]) -> None:
289 """Test bad file ``bad_rst.rst`` without config file not ok."""
290 test_file = EXAMPLES_DIR / "with_configuration" / "bad_rst.rst"
291 config_file = pathlib.Path("NONE")
292 init_config = config.RstcheckConfig(config_path=config_file)
293 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
294
295 result = _runner.run()
296
297 assert result != 0
298 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 2
299
300 @staticmethod
301 def test_bad_file_1_with_implicit_config_no_errors(capsys: pytest.CaptureFixture[str]) -> None:
302 """Test bad file ``bad.rst`` with implicit config file is ok."""
303 test_file = EXAMPLES_DIR / "with_configuration" / "bad.rst"
304 init_config = config.RstcheckConfig()
305 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
306
307 result = _runner.run()
308
309 assert result == 0
310 assert "Success! No issues detected." in capsys.readouterr().out
311
312 @staticmethod
313 def test_bad_file_2_with_implicit_config_some_errors(
314 capsys: pytest.CaptureFixture[str],
315 ) -> None:
316 """Test bad file ``bad_rst.rst`` with implicit config file partially ok."""
317 test_file = EXAMPLES_DIR / "with_configuration" / "bad_rst.rst"
318 init_config = config.RstcheckConfig()
319 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
320
321 result = _runner.run()
322
323 assert result != 0
324 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 1
325
326 @staticmethod
327 def test_bad_file_1_with_explicit_config_no_errors(capsys: pytest.CaptureFixture[str]) -> None:
328 """Test bad file ``bad.rst`` with explicit config file is ok."""
329 test_file = EXAMPLES_DIR / "with_configuration" / "bad.rst"
330 config_file = EXAMPLES_DIR / "with_configuration" / "rstcheck.ini"
331 init_config = config.RstcheckConfig(config_path=config_file)
332 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
333
334 result = _runner.run()
335
336 assert result == 0
337 assert "Success! No issues detected." in capsys.readouterr().out
338
339 @staticmethod
340 def test_bad_file_2_with_explicit_config_some_errors(
341 capsys: pytest.CaptureFixture[str],
342 ) -> None:
343 """Test bad file ``bad_rst.rst`` with explicit config file partially ok."""
344 test_file = EXAMPLES_DIR / "with_configuration" / "bad_rst.rst"
345 config_file = EXAMPLES_DIR / "with_configuration" / "rstcheck.ini"
346 init_config = config.RstcheckConfig(config_path=config_file)
347 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
348
349 result = _runner.run()
350
351 assert result != 0
352 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 1
353
354
355 class TestWarningOnUnknownSettings:
356 """Test warnings logged on unknown settings in config files."""
357
358 @staticmethod
359 @pytest.mark.parametrize("config_file_name", ["bad_config.cfg", "bad_config.toml"])
360 def test_no_warnings_are_logged_by_default(
361 config_file_name: str,
362 caplog: pytest.LogCaptureFixture,
363 capsys: pytest.CaptureFixture[str],
364 ) -> None:
365 """Test that no warning is logged on unknown setting by default."""
366 test_file = EXAMPLES_DIR / "good" / "rst.rst"
367 config_file = EXAMPLES_DIR / "with_configuration" / config_file_name
368 init_config = config.RstcheckConfig(config_path=config_file)
369 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
370
371 result = _runner.run()
372
373 assert result == 0
374 assert "Success! No issues detected." in capsys.readouterr().out
375 assert "Unknown setting(s)" not in caplog.text
376
377 @staticmethod
378 @pytest.mark.parametrize("config_file_name", ["bad_config.cfg", "bad_config.toml"])
379 def test_no_warnings_are_logged_by_default_on_ini_files(
380 config_file_name: str,
381 caplog: pytest.LogCaptureFixture,
382 capsys: pytest.CaptureFixture[str],
383 ) -> None:
384 """Test that a warning is logged on unknown setting when activated."""
385 test_file = EXAMPLES_DIR / "good" / "rst.rst"
386 config_file = EXAMPLES_DIR / "with_configuration" / config_file_name
387 init_config = config.RstcheckConfig(config_path=config_file, warn_unknown_settings=True)
388 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
389
390 result = _runner.run()
391
392 assert result == 0
393 assert "Success! No issues detected." in capsys.readouterr().out
394 assert "Unknown setting(s)" in caplog.text
395
396
397 class TestCustomDirectivesAndRoles:
398 """Test custom directives and roles."""
399
400 @staticmethod
401 def test_custom_directive_and_role(capsys: pytest.CaptureFixture[str]) -> None:
402 """Test file with custom directive and role."""
403 test_file = EXAMPLES_DIR / "custom" / "custom_directive_and_role.rst"
404 init_config = config.RstcheckConfig()
405 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
406
407 result = _runner.run()
408
409 assert result != 0
410 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 4
411
412 @staticmethod
413 def test_custom_directive_and_role_with_ignore(capsys: pytest.CaptureFixture[str]) -> None:
414 """Test file with custom directive and role and CLI ignores."""
415 test_file = EXAMPLES_DIR / "custom" / "custom_directive_and_role.rst"
416 init_config = config.RstcheckConfig(
417 ignore_directives="custom-directive", ignore_roles="custom-role"
418 )
419 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
420
421 result = _runner.run()
422
423 assert result == 0
424 assert "Success! No issues detected." in capsys.readouterr().out
425
426 @staticmethod
427 def test_custom_directive_and_role_with_config_file(
428 capsys: pytest.CaptureFixture[str],
429 ) -> None:
430 """Test file with custom directive and role and config file."""
431 test_file = EXAMPLES_DIR / "custom" / "custom_directive_and_role.rst"
432 config_file = EXAMPLES_DIR / "custom" / "rstcheck.custom.ini"
433 init_config = config.RstcheckConfig(config_path=config_file)
434 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
435
436 result = _runner.run()
437
438 assert result == 0
439 assert "Success! No issues detected." in capsys.readouterr().out
440
441
442 class TestSphinx:
443 """Test integration with sphinx."""
444
445 @staticmethod
446 @pytest.mark.skipif(_extras.SPHINX_INSTALLED, reason="Test without sphinx extra.")
447 def test_sphinx_role_erros_without_sphinx(capsys: pytest.CaptureFixture[str]) -> None:
448 """Test sphinx example errors without sphinx."""
449 test_file = EXAMPLES_DIR / "sphinx" / "good.rst"
450 init_config = config.RstcheckConfig()
451 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
452
453 result = _runner.run()
454
455 assert result != 0
456 assert len(ERROR_CODE_REGEX.findall(capsys.readouterr().err)) == 2
457
458 @staticmethod
459 @pytest.mark.skipif(not _extras.SPHINX_INSTALLED, reason="Depends on sphinx extra.")
460 def test_sphinx_role_exits_zero_with_sphinx(capsys: pytest.CaptureFixture[str]) -> None:
461 """Test sphinx example does not error with sphinx."""
462 test_file = EXAMPLES_DIR / "sphinx" / "good.rst"
463 init_config = config.RstcheckConfig()
464 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
465
466 result = _runner.run()
467
468 assert result == 0
469 assert "Success! No issues detected." in capsys.readouterr().out
470
471
472 class TestInlineIgnoreComments:
473 """Test inline config comments to ignore things."""
474
475 @staticmethod
476 def test_bad_example_has_issues(capsys: pytest.CaptureFixture[str]) -> None:
477 """Test all issues are found on bad example."""
478 test_file = EXAMPLES_DIR / "inline_config" / "without_inline_ignore.rst"
479 init_config = config.RstcheckConfig()
480 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
481
482 result = _runner.run()
483
484 assert result != 0
485 stderr = capsys.readouterr().err
486 assert len(ERROR_CODE_REGEX.findall(stderr)) == 6
487 assert "custom-directive" in stderr
488 assert "custom-role" in stderr
489 assert "python" in stderr
490 assert "unmatched-substitution" in stderr
491
492 @staticmethod
493 def test_bad_example_has_no_issues_with_inline_ignores(
494 capsys: pytest.CaptureFixture[str],
495 ) -> None:
496 """Test no issues are found on bad example with ignore comments."""
497 test_file = EXAMPLES_DIR / "inline_config" / "with_inline_ignore.rst"
498 init_config = config.RstcheckConfig()
499 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
500
501 result = _runner.run()
502
503 assert result == 0
504 assert "Success! No issues detected." in capsys.readouterr().out
505
506
507 class TestInlineFlowControlComments:
508 """Test inline flow control comments to e.g. skip things."""
509
510 @staticmethod
511 @pytest.mark.skipif(sys.version_info[0:2] > (3, 9), reason="Requires python3.9 or lower")
512 def test_bad_example_has_only_one_issue_pre310(capsys: pytest.CaptureFixture[str]) -> None:
513 """Test only one issue is detected for two same code-blocks.
514
515 One code-block has skip comment.
516 """
517 test_file = EXAMPLES_DIR / "inline_config" / "with_inline_skip_code_block.rst"
518 init_config = config.RstcheckConfig()
519 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
520
521 result = _runner.run()
522
523 assert result != 0
524 assert len(re.findall(r"unexpected EOF while parsing", capsys.readouterr().err)) == 1
525
526 @staticmethod
527 @pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires python3.10 or higher")
528 def test_bad_example_has_only_one_issue(capsys: pytest.CaptureFixture[str]) -> None:
529 """Test only one issue is detected for two same code-blocks.
530
531 One code-block has skip comment.
532 """
533 test_file = EXAMPLES_DIR / "inline_config" / "with_inline_skip_code_block.rst"
534 init_config = config.RstcheckConfig()
535 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
536
537 result = _runner.run()
538
539 assert result != 0
540 assert len(re.findall(r"'\(' was never closed", capsys.readouterr().err)) == 1
541
542 @staticmethod
543 @pytest.mark.skipif(sys.version_info[0:2] > (3, 9), reason="Requires python3.9 or lower")
544 def test_nested_bad_example_has_only_one_issue_pre310(
545 capsys: pytest.CaptureFixture[str],
546 ) -> None:
547 """Test only one issue is detected for two same nested code-blocks.
548
549 One code-block has skip comment.
550 """
551 test_file = EXAMPLES_DIR / "inline_config" / "with_nested_inline_skip_code_block.rst"
552 init_config = config.RstcheckConfig()
553 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
554
555 result = _runner.run()
556
557 assert result != 0
558 assert len(re.findall(r"unexpected EOF while parsing", capsys.readouterr().err)) == 1
559
560 @staticmethod
561 @pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires python3.10 or higher")
562 def test_nested_bad_example_has_only_one_issue(capsys: pytest.CaptureFixture[str]) -> None:
563 """Test only one issue is detected for two same nested code-blocks.
564
565 One code-block has skip comment.
566 """
567 test_file = EXAMPLES_DIR / "inline_config" / "with_nested_inline_skip_code_block.rst"
568 init_config = config.RstcheckConfig()
569 _runner = runner.RstcheckMainRunner(check_paths=[test_file], rstcheck_config=init_config)
570
571 result = _runner.run()
572
573 assert result != 0
574 assert len(re.findall(r"'\(' was never closed", capsys.readouterr().err)) == 1