Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
self.maxDiff = None
# getting the bash-color-codes from the colorful module
self.red = cf.red.style[0]
self.green = cf.green.style[0]
self.yellow = cf.yellow.style[0]
self.cyan = cf.cyan.style[0]
self.reset = cf.black.style[
1
] # every colors second value is the reset value ...
self.term = Terminal()
self.term.get_width = MagicMock(return_value=80)
def test_add_indent(self, mock_stdout):
term = Terminal()
i = 6
expected_msg = ' ' * i + 'foo\n'
term.add_indent(i)
term.print('foo')
ret = mock_stdout.getvalue()
self.assertEqual(len(ret), len(expected_msg))
self.assertEqual(ret, expected_msg)
# clear the buffer
mock_stdout.truncate(0)
mock_stdout.seek(0)
def test_print(self, mock_stdout):
term = Terminal()
expected_msg = 'foo bar\n'
term.print('foo bar')
ret = mock_stdout.getvalue()
self.assertEqual(len(ret), len(expected_msg))
self.assertEqual(ret, expected_msg)
def test_with_indent(self, mock_stdout):
term = Terminal()
expected_msg = ' foo\n'
with term.indent(2):
term.print('foo')
ret = mock_stdout.getvalue()
self.assertEqual(len(ret), len(expected_msg))
self.assertEqual(ret, expected_msg)
# clear the buffer
mock_stdout.truncate(0)
mock_stdout.seek(0)
term.print('bar')
'-m',
'--mode',
dest='mode',
choices=[str(Mode.PYTHONPATH), str(Mode.PIPENV), str(Mode.POETRY)],
help='Mode for loading autohooks during hook execution. Either load '
'autohooks from the PYTHON_PATH, via pipenv or via poetry.',
)
subparsers.add_parser('check', help='Check installed pre-commit hook')
args = parser.parse_args()
if not args.command:
parser.print_usage()
term = Terminal()
if args.command == 'activate':
install_hooks(term, args)
elif args.command == 'check':
check_hooks(term)