approvals / approvals/ApprovalTests.Python

Should this library provide many configurations of diff reporters?

Open
#198 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
212
Forks
56
Avg merge
1m
Merged PRs (30d)
1

Description

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",
                ],
            )
        )

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading GenericDiffReporter and GenericDiffReporterConfig, then compare them with the configurations the library already provides. Determine which external diff reporters and platform variants are in scope; the work is done when the project has decided whether to include these configurations and the accepted scope is documented or implemented.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.