How to use the approvaltests.core.reporter.Reporter function in approvaltests

To help you get started, we’ve selected a few approvaltests examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github approvals / ApprovalTests.Python / approvaltests / reporters / multi_reporter.py View on Github external
from approvaltests.core.reporter import Reporter


class MultiReporter(Reporter):
    def __init__(self, *reporters):
        self.reporters = reporters

    def report(self, received_path, approved_path):
        for r in self.reporters:
            r.report(received_path, approved_path)
github approvals / ApprovalTests.Python / approvaltests / reporters / first_working_reporter.py View on Github external
from approvaltests.core.reporter import Reporter


class FirstWorkingReporter(Reporter):
    def __init__(self, *reporters):
        self.reporters = reporters

    def report(self, received_path, approved_path):
        for r in self.reporters:
            try:
                success = r.report(received_path, approved_path)
                if success:
                    return True
            except:
                pass

        return False
github approvals / ApprovalTests.Python / approvaltests / reporters / testing_reporter.py View on Github external
from approvaltests.core.reporter import Reporter


class ReporterForTesting(Reporter):

    def __init__(self):
        self.called = False

    def report(self, approved_path, received_path):
        self.called = True
github approvals / ApprovalTests.Python / approvaltests / reporters / clipboard_reporter.py View on Github external
import pyperclip

from approvaltests.core.reporter import Reporter


def get_command_text(received_path, approved_path):
    return 'mv -f {0} {1}'.format(received_path, approved_path)


class ClipboardReporter(Reporter):
    def report(self, received_path, approved_path):
        text = get_command_text(received_path, approved_path)
        print(text)
        pyperclip.copy(text)
        return True


class CommandLineReporter(Reporter):
    def report(self, received_path, approved_path):
        text = get_command_text(received_path, approved_path)
        print('\n\n{}\n\n'.format(text))
        return True
github approvals / ApprovalTests.Python / approvaltests / reporters / generic_diff_reporter.py View on Github external
import json
import os
import subprocess

from approvaltests.command import Command
from approvaltests.core.reporter import Reporter
from approvaltests.utils import to_json


class GenericDiffReporter(Reporter):
    @staticmethod
    def create(diff_tool_path):
        return GenericDiffReporter(['custom', diff_tool_path])

    def __init__(self, config):
        self.name = config[0]
        self.path = config[1]
        if len(config) > 2:
            self.extra_args = config[2]
        else:
            self.extra_args = []

    def __str__(self):
        config = {
            'name': self.name,
            'path': self.path
github approvals / ApprovalTests.Python / tests / reporters / test_first_working_reporter.py View on Github external
import unittest

from approvaltests.core.reporter import Reporter
from approvaltests.reporters.first_working_reporter import FirstWorkingReporter


class ReporterForTesting(Reporter):
    def __init__(self, success, additional=None):
        if additional is None:
            additional = lambda : None
        self.additional = additional
        self.called = False
        self.success = success

    def report(self, received_path, approved_path):
        self.called = True
        self.additional()
        return self.success


class TestFirstWorkingReporter(unittest.TestCase):
    def test_first_one(self):
        r1 = ReporterForTesting(True)
github approvals / ApprovalTests.Python / approvaltests / reporters / clipboard_reporter.py View on Github external
from approvaltests.core.reporter import Reporter


def get_command_text(received_path, approved_path):
    return 'mv -f {0} {1}'.format(received_path, approved_path)


class ClipboardReporter(Reporter):
    def report(self, received_path, approved_path):
        text = get_command_text(received_path, approved_path)
        print(text)
        pyperclip.copy(text)
        return True


class CommandLineReporter(Reporter):
    def report(self, received_path, approved_path):
        text = get_command_text(received_path, approved_path)
        print('\n\n{}\n\n'.format(text))
        return True
github approvals / ApprovalTests.Python / approvaltests / reporters / received_file_launcher_reporter.py View on Github external
from subprocess import call

from approvaltests.core.reporter import Reporter


class ReceivedFileLauncherReporter(Reporter):

    @staticmethod
    def get_command(approved_path, received_path):
        return ['cmd', '/C', 'start', received_path, '/B']

    def report(self, approved_path, received_path):
        command_array = self.get_command(approved_path, received_path)
        call(command_array)