Debian Codegraph @

tests/unit_tests/test_exception.py

raw
1 from __future__ import annotations
2
3 import subprocess
4 from typing import Callable
5
6
7 def test_pretty_print_warning_goes_to_stderr(
8 run_python: Callable[[str], subprocess.CompletedProcess[str]],
9 ) -> None:
10 """stdout belongs to query output; diagnostics go to stderr.
11
12 `pretty_print_error` has always got this right. `pretty_print_warning` used
13 `rich.print`, which writes to stdout -- and it is reached from the CLI path
14 by both the locale manager and the Windows tzdata installer.
15 """
16 proc = run_python(
17 "from harlequin.exception import pretty_print_warning\n"
18 "pretty_print_warning(title='A Title', message='A message.')\n"
19 )
20 assert proc.stdout == ""
21 assert "A message." in proc.stderr