MCPcopy
hub / github.com/pallets/click / test_isolation_flushes_unflushed_stderr

Function test_isolation_flushes_unflushed_stderr

tests/test_testing.py:468–485  ·  view source on GitHub ↗

An un-flushed write to stderr, as with `print(..., file=sys.stderr)`, will end up flushed by the runner at end of invocation.

()

Source from the content-addressed store, hash-verified

466
467
468def test_isolation_flushes_unflushed_stderr():
469 """An un-flushed write to stderr, as with `print(..., file=sys.stderr)`, will end up
470 flushed by the runner at end of invocation.
471 """
472 runner = CliRunner()
473
474 with runner.isolation() as (_, err, _):
475 click.echo("\udce2", err=True, nl=False)
476 assert err.getvalue() == b"\\udce2"
477
478 @click.command()
479 def cli():
480 # set end="", flush=False so that it's totally clear that we won't get any
481 # auto-flush behaviors
482 print("gyarados gyarados gyarados", file=sys.stderr, end="", flush=False)
483
484 result = runner.invoke(cli)
485 assert result.stderr == "gyarados gyarados gyarados"
486
487
488def test_pdb_uses_real_streams():

Callers

nothing calls this directly

Calls 4

isolationMethod · 0.95
invokeMethod · 0.95
CliRunnerClass · 0.90
getvalueMethod · 0.80

Tested by

no test coverage detected