File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import subprocess
2+ import sys
3+
4+ import pytest
5+
6+
7+ def test_importtime__no_mdit_import ():
8+ """Test that `markdown_it` isn't imported when `mdformat` and
9+ `mdformat._cli` are.
10+
11+ Do this in a subprocess to have a clean environment separate from
12+ pytest and other tests.
13+ """
14+ test_script = """\
15+ import sys
16+ import mdformat
17+ import mdformat._cli
18+ assert 'markdown_it' not in sys.modules, 'markdown_it was imported'
19+ """
20+ result = subprocess .run (
21+ [sys .executable , "-c" , test_script ],
22+ stdin = subprocess .DEVNULL ,
23+ stderr = subprocess .PIPE ,
24+ )
25+ if result .returncode :
26+ assert (
27+ b"markdown_it was imported" in result .stderr
28+ ), "unexpected error in subprocess"
29+ pytest .fail ("markdown_it was imported" )
You can’t perform that action at this time.
0 commit comments