@@ -187,7 +187,7 @@ class DirectiveTestCase:
187187 example_block : str | None = None
188188 run_block : str | None = None
189189 document : str | None = None
190- html_matches : Sequence [str ] = None
190+ html_matches : Sequence [str ] | None = None
191191
192192 def __post_init__ (self ):
193193 self .html_matches = self .html_matches or tuple ()
@@ -379,7 +379,7 @@ def simple_print():
379379
380380SHOW_SOURCE_TEST_CASE = DirectiveTestCase (
381381 # Test that :show-source: option shows source code in click:run directive.
382- name = "show_source_ " ,
382+ name = "show_source " ,
383383 example_block = """
384384 from click import command, echo
385385
@@ -674,7 +674,7 @@ def bad_format():
674674
675675 .. click:run::
676676
677- invoke(bad_format, [] )
677+ invoke(bad_format)
678678 """ )
679679
680680 # RST should fail to parse this malformed directive.
@@ -809,44 +809,26 @@ def cmd2():
809809 (
810810 RST ,
811811 """\
812- .. click:example::
813-
814- from click import command, echo
815-
816- @command
817- def hello():
818- echo("Hello World!")
819-
820812 .. click:run::
821813
822814 # This should fail due to variable conflict.
823815 {var_name} = "Do not overwrite me!"
824- result = invoke(hello)
825816 """ ,
826- 9 ,
827- 12 ,
817+ 1 ,
818+ 4 ,
828819 ),
829820 (
830821 MYST ,
831822 """\
832- ```{{click:example}}
833- from click import command, echo
834-
835- @command
836- def hello():
837- echo("Hello World!")
838- ```
839-
840823 ```{{click:run}}
841824 # This should fail due to variable conflict.
842825 {var_name} = "Do not overwrite me!"
843- result = invoke(hello)
844826 ```
845827 """ ,
846- 9 ,
847- 11 ,
828+ 1 ,
829+ 3 ,
848830 ),
849- # Check proper line number reporting with preceding blank lines.
831+ # Check proper line number reporting with preceding lines.
850832 (
851833 RST ,
852834 """
@@ -893,13 +875,16 @@ def hello():
893875 9 + 4 ,
894876 11 + 4 ,
895877 ),
878+ # Check proper line number reporting with blank lines within the directive.
896879 (
897880 RST ,
898881 """\
899882 .. click:run::
900883
901884 # This should fail due to variable conflict.
902885 {var_name} = "Do not overwrite me!"
886+
887+
903888 """ ,
904889 1 ,
905890 4 ,
@@ -910,6 +895,8 @@ def hello():
910895 ```{{click:run}}
911896 # This should fail due to variable conflict.
912897 {var_name} = "Do not overwrite me!"
898+
899+
913900 ```
914901 """ ,
915902 1 ,
@@ -966,7 +953,32 @@ def hello():
966953 1 ,
967954 4 ,
968955 ),
969- # Options should not affect line numbering.
956+ (
957+ RST ,
958+ """\
959+ .. click:run::
960+ :linenos:
961+ :lineno-start: 10
962+
963+ # This should fail due to variable conflict.
964+ {var_name} = "Do not overwrite me!"
965+ """ ,
966+ 1 ,
967+ 6 ,
968+ ),
969+ (
970+ MYST ,
971+ """\
972+ ```{{click:run}}
973+ :linenos:
974+ :lineno-start: 10
975+ # This should fail due to variable conflict.
976+ {var_name} = "Do not overwrite me!"
977+ ```
978+ """ ,
979+ 1 ,
980+ 5 ,
981+ ),
970982 (
971983 RST ,
972984 """\
@@ -995,6 +1007,42 @@ def hello():
9951007 1 ,
9961008 6 ,
9971009 ),
1010+ (
1011+ RST ,
1012+ """\
1013+ .. click:run::
1014+ :linenos:
1015+
1016+ # This should fail due to variable conflict.
1017+ {var_name} = "Do not overwrite me!"
1018+
1019+
1020+
1021+ """ ,
1022+ 1 ,
1023+ 5 ,
1024+ ),
1025+ pytest .param (
1026+ MYST ,
1027+ """\
1028+ ```{{click:run}}
1029+ :linenos:
1030+ # This should fail due to variable conflict.
1031+ {var_name} = "Do not overwrite me!"
1032+
1033+
1034+
1035+ ```
1036+ """ ,
1037+ 1 ,
1038+ 4 ,
1039+ marks = pytest .mark .xfail (
1040+ reason = "MyST line reporting is off: "
1041+ "https://github.com/executablebooks/MyST-Parser/pull/1048" ,
1042+ # This is going to fail unless MyST is fixed upstream.
1043+ strict = True ,
1044+ ),
1045+ ),
9981046 ],
9991047 indirect = ["sphinx_app" ],
10001048)
0 commit comments