Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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
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
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
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
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)
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
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)