Debian Codegraph @

tests/integration_tests/cli_test.py

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