Skip to content

Should this library provide many configurations of diff reporters? #198

@matthiasschaub

Description

@matthiasschaub

We use the build-in classes GenericDiffReporter and GenericDiffReporterConfig to configure a bunch of Reporters to use external diff programs for reporting. Should this library provide these configurations (as it does for some already) or is the user expected to set these up by themselves?

I am happy to create a PR in case those should be part of the library.

For example:

from approvaltests.reporters.generic_diff_reporter import GenericDiffReporter
from approvaltests.reporters.generic_diff_reporter_config import (
    GenericDiffReporterConfig,
)


class ReportWithPyCharmLinuxFlatpak(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithPyCharmLinuxFlatpak",
                path="/usr/bin/flatpak",
                extra_args=["run", "com.jetbrains.PyCharm-Community", "diff"],
            )
        )


class ReportWithPyCharmLinux(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithPyCharmLinux",
                path="pycharm",
                extra_args=["diff"],
            )
        )


class ReportWithVSCodeLinux(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithVSCodeLinux",
                path="/usr/bin/code",
                extra_args=["--new-window", "--wait", "--diff"],
            )
        )


class ReportWithPyCharmProfessionalMacOS(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithPyCharmProfessionalMacOS",
                # Use open to block Python until diff tool is closed again
                path="/usr/bin/open",
                extra_args=[
                    # -W: Wait until the application is closed
                    "-W",
                    # -n: new instance
                    "-n",
                    # -a: application
                    "-a",
                    "/Applications/PyCharm Professional Edition.app/Contents/MacOS/pycharm",  # noqa
                    "--args",
                    "diff",
                ],
            )
        )


class ReportWithPyCharmCommunityMacOS(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithPyCharmCommunityMacOS",
                # Use open to block Python until diff tool is closed again
                path="/usr/bin/open",
                extra_args=[
                    # -W: Wait until the application is closed
                    "-W",
                    # -n: New instance
                    "-n",
                    # -a: Application
                    "-a",
                    "/Applications/PyCharm CE.app/Contents/MacOS/pycharm",
                    "--args",
                    "diff",
                ],
            )
        )


class ReportWithVSCodeMacOS(GenericDiffReporter):
    def __init__(self):
        super().__init__(
            config=GenericDiffReporterConfig(
                name="ReportWithVSCodeMacOS",
                # Use open to block Python until diff tool is closed again
                path="/usr/bin/open",
                extra_args=[
                    # -W: Wait until the application is closed
                    "-W",
                    # -n: New instance
                    "-n",
                    # -a: Application
                    "-a",
                    "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code",  # noqa
                    "--args",
                    "--new-window",
                    "--wait",
                    "--diff",
                ],
            )
        )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions