summaryrefslogtreecommitdiff
path: root/tests/test_parse.py
blob: f5846bd73f9c247eec2c7e2f05f183fc6d7a3430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from hypothesis_auto import auto_pytest_magic
from isort import parse
from isort.settings import Config

TEST_CONTENTS = """
import xyz
import abc


def function():
    pass
"""


def test_file_contents():
    (
        in_lines,
        out_lines,
        import_index,
        place_imports,
        import_placements,
        as_map,
        imports,
        categorized_comments,
        change_count,
        original_line_count,
        line_separator,
        sections,
        section_comments,
    ) = parse.file_contents(TEST_CONTENTS, config=Config())
    assert "\n".join(in_lines) == TEST_CONTENTS
    assert "import" not in "\n".join(out_lines)
    assert import_index == 1
    assert change_count == -2
    assert original_line_count == len(in_lines)


auto_pytest_magic(parse.import_type)
auto_pytest_magic(parse.skip_line)
auto_pytest_magic(parse._strip_syntax)
auto_pytest_magic(parse._infer_line_separator)