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

Function test_file_args

tests/test_arguments.py:105–125  ·  view source on GitHub ↗
(runner)

Source from the content-addressed store, hash-verified

103
104
105def test_file_args(runner):
106 @click.command()
107 @click.argument("input", type=click.File("rb"))
108 @click.argument("output", type=click.File("wb"))
109 def inout(input, output):
110 while True:
111 chunk = input.read(1024)
112 if not chunk:
113 break
114 output.write(chunk)
115
116 with runner.isolated_filesystem():
117 result = runner.invoke(inout, ["-", "hello.txt"], input="Hey!")
118 assert result.output == ""
119 assert result.exit_code == 0
120 with open("hello.txt", "rb") as f:
121 assert f.read() == b"Hey!"
122
123 result = runner.invoke(inout, ["hello.txt", "-"])
124 assert result.output == "Hey!"
125 assert result.exit_code == 0
126
127
128def test_path_allow_dash(runner):

Callers

nothing calls this directly

Calls 4

openFunction · 0.85
isolated_filesystemMethod · 0.80
readMethod · 0.80
invokeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…