Coverage for tests/test_up_to_py39.py: 100%

12 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2026-10-15 15:22 +0000

1import inspect 1ab

2 

3import markdown 1ab

4from inline_snapshot import snapshot 1ab

5 

6from markdown_include_variants import IncludeVariantsExtension 1ab

7 

8 

9def test_all_variants_plain(): 1ab

10 input_md = inspect.cleandoc( 1cd

11 """ 

12 {* docs_src/up_to_py39/tutorial001_an_py39.py *} 

13 """ 

14 ) 

15 

16 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1cd

17 assert result == snapshot( 1cd

18 inspect.cleandoc( 

19 """ 

20 <p>//// tab | Python 3.9+ 

21 <code>python 

22 {!docs_src/up_to_py39/tutorial001_an_py39.py!}</code></p> 

23 <p>////</p> 

24 <p>///// details | 🤓 Other versions and variants</p> 

25 <p>//// tab | Python 3.8+</p> 

26 <p><code>python 

27 {!docs_src/up_to_py39/tutorial001_an.py!}</code> 

28 //// 

29 //// tab | Python 3.9+ - non-Annotated</p> 

30 <p>/// tip</p> 

31 <p>Prefer to use the <code>Annotated</code> version if possible.</p> 

32 <p>///</p> 

33 <p><code>python 

34 {!docs_src/up_to_py39/tutorial001_py39.py!}</code> 

35 //// 

36 //// tab | Python 3.8+ - non-Annotated</p> 

37 <p>/// tip</p> 

38 <p>Prefer to use the <code>Annotated</code> version if possible.</p> 

39 <p>///</p> 

40 <p><code>python 

41 {!docs_src/up_to_py39/tutorial001.py!}</code> 

42 ////</p> 

43 <p>/////</p> 

44 """ 

45 ) 

46 ) 

47 

48 

49def test_all_variants_ln_hl(): 1ab

50 input_md = inspect.cleandoc( 1ef

51 """ 

52 {* docs_src/up_to_py39/tutorial001_an_py39.py ln[3:5] hl[4:5] *} 

53 """ 

54 ) 

55 

56 result = markdown.markdown(input_md, extensions=[IncludeVariantsExtension()]) 1ef

57 assert result == snapshot( 1ef

58 inspect.cleandoc( 

59 """ 

60 <p>//// tab | Python 3.9+ 

61 ```python hl_lines="4-5"</p> 

62 <h1>Code above omitted 👆</h1> 

63 <p>{!docs_src/up_to_py39/tutorial001_an_py39.py[ln:3-5]!}</p> 

64 <h1>Code below omitted 👇</h1> 

65 <p>```</p> 

66 <p>////</p> 

67 <p>///// details | 👀 Full file preview</p> 

68 <p>//// tab | Python 3.9+</p> 

69 <p><code>python hl_lines="4-5" 

70 {!docs_src/up_to_py39/tutorial001_an_py39.py!}</code></p> 

71 <p>////</p> 

72 <p>/////</p> 

73 <p>///// details | 🤓 Other versions and variants</p> 

74 <p>//// tab | Python 3.8+</p> 

75 <p><code>python 

76 {!docs_src/up_to_py39/tutorial001_an.py!}</code> 

77 //// 

78 //// tab | Python 3.9+ - non-Annotated</p> 

79 <p>/// tip</p> 

80 <p>Prefer to use the <code>Annotated</code> version if possible.</p> 

81 <p>///</p> 

82 <p><code>python 

83 {!docs_src/up_to_py39/tutorial001_py39.py!}</code> 

84 //// 

85 //// tab | Python 3.8+ - non-Annotated</p> 

86 <p>/// tip</p> 

87 <p>Prefer to use the <code>Annotated</code> version if possible.</p> 

88 <p>///</p> 

89 <p><code>python 

90 {!docs_src/up_to_py39/tutorial001.py!}</code> 

91 ////</p> 

92 <p>/////</p> 

93 """ 

94 ) 

95 )