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

Function test_file_args

tests/test_arguments.py:105–125  ·  tests/test_arguments.py::test_file_args
(runner)

Source from the content-addressed store, hash-verified

103
104
105def test_file_args(runner):
106 @click.command()
107 @click.argument(class="st">"input", type=click.File(class="st">"rb"))
108 @click.argument(class="st">"output", type=click.File(class="st">"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, [class="st">"-", class="st">"hello.txt"], input=class="st">"Hey!")
118 assert result.output == class="st">""
119 assert result.exit_code == 0
120 with open(class="st">"hello.txt", class="st">"rb") as f:
121 assert f.read() == bclass="st">"Hey!"
122
123 result = runner.invoke(inout, [class="st">"hello.txt", class="st">"-"])
124 assert result.output == class="st">"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