Coverage for tests/test_simple_no_configs.py: 100%
30 statements
« prev ^ index » next coverage.py v7.6.1, created at 2026-10-15 15:22 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2026-10-15 15:22 +0000
1import inspect 1ab
3import markdown 1ab
4import pytest 1ab
5from inline_snapshot import snapshot 1ab
6from mdx_include.mdx_include import IncludeExtension 1ab
8from markdown_include_variants import IncludeVariantsExtension 1ab
11def test_simple(): 1ab
12 input_md = inspect.cleandoc( 1cd
13 """
14 {*docs_src/simple/tutorial001.py*}
15 """
16 )
18 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1cd
19 assert result == snapshot( 1cd
20 inspect.cleandoc(
21 """
22 <p>//// tab | Python 3.8+
23 <code>python
24 {!docs_src/simple/tutorial001.py!}</code></p>
25 <p>////</p>
26 """
27 )
28 )
31def test_simple_space(): 1ab
32 input_md = inspect.cleandoc( 1ef
33 """
34 {* docs_src/simple/tutorial001.py *}
35 """
36 )
38 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1ef
39 assert result == snapshot( 1ef
40 inspect.cleandoc(
41 """
42 <p>//// tab | Python 3.8+
43 <code>python
44 {!docs_src/simple/tutorial001.py!}</code></p>
45 <p>////</p>
46 """
47 )
48 )
51def test_simple_extra_space(): 1ab
52 input_md = inspect.cleandoc( 1gh
53 """
54 {* docs_src/simple/tutorial001.py *}
55 """
56 )
58 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1gh
59 assert result == snapshot( 1gh
60 inspect.cleandoc(
61 """
62 <p>//// tab | Python 3.8+
63 <code>python
64 {!docs_src/simple/tutorial001.py!}</code></p>
65 <p>////</p>
66 """
67 )
68 )
71def test_simple_include(): 1ab
72 input_md = inspect.cleandoc( 1ij
73 """
74 {* docs_src/simple/tutorial001.py *}
75 """
76 )
78 result = markdown.markdown( 1ij
79 input_md, extensions=[IncludeVariantsExtension(), IncludeExtension()]
80 )
81 assert result == snapshot( 1ij
82 inspect.cleandoc(
83 """
84 <p>//// tab | Python 3.8+
85 ```python
86 print("simple line 1")
87 print("simple line 2")
88 print("simple line 3")
89 print("simple line 4")
90 print("simple line 5")
91 print("simple line 6")
92 print("simple line 7")
93 print("simple line 8")
94 print("simple line 9")
95 print("simple line 10")</p>
96 <p>```</p>
97 <p>////</p>
98 """
99 )
100 )
103def test_simple_no_directive(): 1ab
104 input_md = inspect.cleandoc( 1kl
105 """
106 {! docs_src/simple/tutorial001.py !}
107 """
108 )
110 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1kl
111 assert result == snapshot("<p>{! docs_src/simple/tutorial001.py !}</p>") 1kl
114def test_simple_no_variants(): 1ab
115 input_md = inspect.cleandoc( 1mn
116 """
117 {* docs_src/simple/tutorial002.py *}
118 """
119 )
120 with pytest.raises(FileNotFoundError): 1mn
121 markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1mn