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

Function test_bytes

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

Source from the content-addressed store, hash-verified

121@ALL_PYTHONS
122@ALL_SOURCES
123def test_bytes(generate_threads, python, tmpdir):
124 # GIVEN
125 _, python_executable = python
126
127 program_template = """
128import sys
129import time
130
131
132def first_func():
133 the_local = b"Hello world"
134 second_func(the_local)
135
136def second_func(the_argument):
137 fifo = sys.argv[1]
138 with open(sys.argv[1], "w") as fifo:
139 fifo.write("ready")
140 time.sleep(1000)
141
142first_func()
143 """
144
145 script = tmpdir / "the_script.py"
146 script.write_text(program_template, encoding="utf-8")
147
148 # WHEN
149
150 threads = generate_threads(python_executable, script, tmpdir)
151
152 # THEN
153
154 assert len(threads) == 1
155 (thread,) = threads
156
157 frames = list(thread.frames)
158 assert (len(frames)) == 3
159
160 first_func_frame = find_frame(frames, "first_func")
161 assert "the_local" in first_func_frame.locals
162 assert "Hello world" in first_func_frame.locals["the_local"]
163
164 second_func_frame = find_frame(frames, "second_func")
165 assert "the_argument" in second_func_frame.arguments
166 assert "Hello world" in second_func_frame.arguments["the_argument"]
167
168
169@ALL_PYTHONS

Callers

nothing calls this directly

Calls 1

find_frameFunction · 0.85

Tested by

no test coverage detected