(generate_threads, python, tmpdir)
| 169 | @ALL_PYTHONS |
| 170 | @ALL_SOURCES |
| 171 | def test_bytes_with_binary_data(generate_threads, python, tmpdir): |
| 172 | # GIVEN |
| 173 | _, python_executable = python |
| 174 | |
| 175 | program_template = b""" |
| 176 | import sys |
| 177 | import time |
| 178 | |
| 179 | |
| 180 | def first_func(): |
| 181 | the_local = b"\\xFF" |
| 182 | second_func(the_local) |
| 183 | |
| 184 | def 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 | |
| 190 | first_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 |
nothing calls this directly
no test coverage detected