Debian Codegraph @

tests/unit/test_action_comments.py

raw
1 """Tests for isort action comments, such as isort: skip"""
2
3 import isort
4
5
6 def test_isort_off_and_on() -> None:
7 """Test so ensure isort: off action comment and associated on action comment work together"""
8
9 # as top of file comment
10 assert (
11 isort.code(
12 """# isort: off
13 import a
14 import a
15
16 # isort: on
17 import a
18 import a
19 """
20 )
21 == """# isort: off
22 import a
23 import a
24
25 # isort: on
26 import a
27 """
28 )
29 # as middle comment
30 assert (
31 isort.code(
32 """
33 import a
34 import a
35
36 # isort: off
37 import a
38 import a
39 """
40 )
41 == """
42 import a
43
44 # isort: off
45 import a
46 import a
47 """
48 )
49
50
51 def test_skip_sort_reexports() -> None:
52 code = """my_list = [\"bee\", \"Albatross\", \"Dinosaur\", \"cat\"]
53 __all__ = my_list # isort: skip
54 """
55
56 assert isort.code(code, sort_reexports=True) == code