Пример #1
0
def test_debug_dump(capsys):
    debug_dump([(1, ["black"], ["chunks"])], "old content", "new content",
               [2, 3])
    assert capsys.readouterr().out == (dedent("""\
            --------------------------------------------------------------------------------
             -   1 black
             +     chunks
            --------------------------------------------------------------------------------
            """))
Пример #2
0
def test_debug_dump(caplog, capsys):
    """darker.utils.debug_dump()"""
    caplog.set_level(logging.DEBUG)
    debug_dump([(1, ("black", ), ("chunks", ))], [2, 3])
    assert capsys.readouterr().out == (dedent("""\
            --------------------------------------------------------------------------------
             -   1 black
             +     chunks
            --------------------------------------------------------------------------------
            """))
Пример #3
0
def verify_ast_unchanged(
    edited_to_file: TextDocument,
    reformatted: TextDocument,
    black_chunks: List[DiffChunk],
    edited_linenums: List[int],
) -> None:
    """Verify that source code parses to the same AST before and after reformat"""
    try:
        assert_equivalent(edited_to_file.string, reformatted.string)
    except AssertionError as exc_info:
        debug_dump(black_chunks, edited_to_file, reformatted, edited_linenums)
        raise NotEquivalentError(str(exc_info))
Пример #4
0
def verify_ast_unchanged(
    edited_to_file_str: str,
    reformatted_str: str,
    black_chunks: List[Tuple[int, List[str], List[str]]],
    edited_linenums: List[int],
) -> None:
    """Verify that source code parses to the same AST before and after reformat"""
    try:
        assert_equivalent(edited_to_file_str, reformatted_str)
    except AssertionError as exc_info:
        debug_dump(black_chunks, edited_to_file_str, reformatted_str, edited_linenums)
        raise NotEquivalentError(str(exc_info))
Пример #5
0
def test_debug_dump(capsys):
    debug_dump(
        [(1, ("black",), ("chunks",))],
        TextDocument.from_str("old content"),
        TextDocument.from_str("new content"),
        [2, 3],
    )
    assert capsys.readouterr().out == (
        dedent(
            """\
            --------------------------------------------------------------------------------
             -   1 black
             +     chunks
            --------------------------------------------------------------------------------
            """
        )
    )