How to use the autohooks.terminal.Terminal function in autohooks

To help you get started, we’ve selected a few autohooks 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 greenbone / autohooks / tests / test_terminal.py View on Github external
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)
github greenbone / autohooks / tests / test_terminal.py View on Github external
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)
github greenbone / autohooks / tests / test_terminal.py View on Github external
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)
github greenbone / autohooks / tests / test_terminal.py View on Github external
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')
github greenbone / autohooks / autohooks / cli / __init__.py View on Github external
'-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)