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

Function test_file_option

tests/test_basic.py:337–355  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

335
336
337def test_file_option(runner):
338 @click.command()
339 @click.option("--file", type=click.File("w"))
340 def input(file):
341 file.write("Hello World!\n")
342
343 @click.command()
344 @click.option("--file", type=click.File("r"))
345 def output(file):
346 click.echo(file.read())
347
348 with runner.isolated_filesystem():
349 result_in = runner.invoke(input, ["--file=example.txt"])
350 result_out = runner.invoke(output, ["--file=example.txt"])
351
352 assert not result_in.exception
353 assert result_in.output == ""
354 assert not result_out.exception
355 assert result_out.output == "Hello World!\n\n"
356
357
358def test_file_lazy_mode(runner):

Callers

nothing calls this directly

Calls 2

isolated_filesystemMethod · 0.80
invokeMethod · 0.45

Tested by

no test coverage detected