MCPcopy Create free account
hub / github.com/bloomberg/pystack / test_bytes_with_binary_data

Function test_bytes_with_binary_data

tests/integration/test_local_variables.py:171–214  ·  view source on GitHub ↗
(generate_threads, python, tmpdir)

Source from the content-addressed store, hash-verified

169@ALL_PYTHONS
170@ALL_SOURCES
171def test_bytes_with_binary_data(generate_threads, python, tmpdir):
172 # GIVEN
173 _, python_executable = python
174
175 program_template = b"""
176import sys
177import time
178
179
180def first_func():
181 the_local = b"\\xFF"
182 second_func(the_local)
183
184def second_func(the_argument):
185 fifo = sys.argv[1]
186 with open(sys.argv[1], "w") as fifo:
187 fifo.write("ready")
188 time.sleep(1000)
189
190first_func()
191 """
192
193 script = tmpdir / "the_script.py"
194 script.write_binary(program_template)
195
196 # WHEN
197
198 threads = generate_threads(python_executable, script, tmpdir)
199
200 # THEN
201
202 assert len(threads) == 1
203 (thread,) = threads
204
205 frames = list(thread.frames)
206 assert (len(frames)) == 3
207
208 first_func_frame = find_frame(frames, "first_func")
209 assert "the_local" in first_func_frame.locals
210 assert first_func_frame.locals["the_local"] == "<BINARY>"
211
212 second_func_frame = find_frame(frames, "second_func")
213 assert "the_argument" in second_func_frame.arguments
214 assert second_func_frame.arguments["the_argument"] == "<BINARY>"
215
216
217@ALL_PYTHONS

Callers

nothing calls this directly

Calls 1

find_frameFunction · 0.85

Tested by

no test coverage detected