summaryrefslogtreecommitdiff
path: root/tests/unit/utils.py
blob: 9c963d63788ad1bb1cc69f5a4c9fd073a5ce85a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import isort


def isort_test(code: str, expected_output: str = "", **config):
    """Runs isort against the given code snippet and ensures that it
    gives consistent output accross multiple runs, and if an expected_output
    is given - that it matches that.
    """
    expected_output = expected_output or code

    output = isort.code(code, **config)
    assert output == expected_output

    assert output == isort.code(output, **config)