Esempio n. 1
0
def check_out(result: Union[Result, CaptureResult[str]],
              advanced_data_regression: AdvancedDataRegressionFixture):

    if hasattr(result, "stdout"):
        stdout = result.stdout
    else:
        stdout = result.out

    if hasattr(result, "stderr"):
        stderr = result.stderr
    else:
        stderr = result.err

    data_dict = {
        "out": strip_ansi(path_sub.sub(" ...", stdout)).split('\n'),
        "err": strip_ansi(path_sub.sub(" ...", stderr)).split('\n'),
    }

    advanced_data_regression.check(data_dict)
Esempio n. 2
0
def test_print_256_colour_testpattern(
    monkeypatch,
    file_regression: FileRegressionFixture,
    capsys,
):
    monkeypatch.setattr(terminal_colours, "resolve_color_default",
                        lambda *args: False)

    # Checks only the structure, not the colours
    print_256_colour_testpattern()

    check_file_regression(strip_ansi(capsys.readouterr().out.strip()),
                          file_regression)
Esempio n. 3
0
    def format_help_text(self, ctx: click.Context,
                         formatter: click.formatting.HelpFormatter):
        """
		Writes the help text to the formatter if it exists.

		:param ctx:
		:param formatter:
		"""

        doc = block_token.Document(self.help or '')

        with TerminalRenderer() as renderer:
            rendered_doc = indent(renderer.render(doc).strip(), "  ")

        if resolve_color_default(self._colour) is False:
            # Also remove 'COMBINING LONG STROKE OVERLAY', used for strikethrough.
            rendered_doc = strip_ansi(rendered_doc).replace('̶', '')

        formatter.write('\n')
        formatter.write(rendered_doc)
        formatter.write('\n')