<commit_before>from pytest import skip

from invocations.checks import blacken


class checks:

    class blacken_:

        def base_case_is_all_files_and_79_characters(self, ctx):
            blacken(ctx)
            ctx.run.assert_called_once_with(
                "find . -name '*.py' | xargs black -l 79", pty=True
            )

        def line_length_configurable(self, ctx):
            blacken(ctx, line_length=80)
            ctx.run.assert_called_once_with(
                "find . -name '*.py' | xargs black -l 80", pty=True
            )

        def target_folders_configurable(self, ctx):
            blacken(ctx, folder=["foo", "bar"])
            ctx.run.assert_called_once_with(
                "find foo bar -name '*.py' | xargs black -l 79", pty=True
            )

        def check_flag_passed_through(self, ctx):
            blacken(ctx, check=True)
            ctx.run.assert_called_once_with(
                "find . -name '*.py' | xargs black -l 79 --check", pty=True
            )

        def diff_flag_passed_through(self, ctx):
            blacken(ctx, diff=True)
            ctx.run.assert_called_once_with(
                "find . -name '*.py' | xargs black -l 79 --diff", pty=True
            )

        def multiple_options_given_simultaneously(self, ctx):
            blacken(
                ctx,
                diff=True,
                check=True,
                line_length=80,
                folder=["foo", "bar"],
            )
            ctx.run.assert_called_once_with(
                "find foo bar -name '*.py' | xargs black -l 80 --check --diff",
                pty=True,
            )

        def subfolders_can_be_ignored(self):
            # TODO: how best to do this? there's no way at all to ignore
            # vendor/ currently, even if you "opt in" you can't give the top
            # level to get tasks.py, setup.py etc as it's recursive by default
            # TODO: probably best to just make it a catchall opts passthru to
            # find???
            skip()<commit_msg>Experimenting with pytest parameterization<commit_after>import pytest

from invocations.checks import blacken


class checks:

    class blacken_:

        @pytest.mark.parametrize(
            "kwargs,command",
            [
                (dict(), "find . -name '*.py' | xargs black -l 79"),
                (
                    dict(line_length=80),
                    "find . -name '*.py' | xargs black -l 80",
                ),
                (
                    dict(folder=["foo", "bar"]),
                    "find foo bar -name '*.py' | xargs black -l 79",
                ),
                (
                    dict(check=True),
                    "find . -name '*.py' | xargs black -l 79 --check",
                ),
                (
                    dict(diff=True),
                    "find . -name '*.py' | xargs black -l 79 --diff",
                ),
                (
                    dict(
                        diff=True,
                        check=True,
                        line_length=80,
                        folder=["foo", "bar"],
                    ),
                    "find foo bar -name '*.py' | xargs black -l 80 --check --diff",  # noqa
                ),
                # TODO: extra arbitrary 'find' opts passthru
            ],
        )
        def runs_black(self, ctx, kwargs, command):
            blacken(ctx, **kwargs)
            ctx.run.assert_called_once_with(command, pty=True)
{'fraction_non_alphanumeric': 0.10723477266228196, 'fraction_numerical': 0.009722619388046897, 'mean_word_length': 1.2611506140917905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6490100', 'n_tokens_mistral': 1051, 'n_tokens_neox': 961, 'n_words': 253}