(generate_threads, python, tmpdir)
| 217 | @ALL_PYTHONS |
| 218 | @ALL_SOURCES |
| 219 | def test_split_dict(generate_threads, python, tmpdir): |
| 220 | # GIVE |
| 221 | _, python_executable = python |
| 222 | |
| 223 | program_template = """ |
| 224 | import sys |
| 225 | import time |
| 226 | |
| 227 | class A: |
| 228 | def __init__(self, x, y): |
| 229 | self.x = x |
| 230 | self.y = y |
| 231 | |
| 232 | a = A(1, "barbaridad") |
| 233 | |
| 234 | def first_func(): |
| 235 | the_local = a.__dict__ |
| 236 | second_func(a.__dict__) |
| 237 | |
| 238 | def second_func(the_argument): |
| 239 | fifo = sys.argv[1] |
| 240 | with open(sys.argv[1], "w") as fifo: |
| 241 | fifo.write("ready") |
| 242 | time.sleep(1000) |
| 243 | |
| 244 | first_func() |
| 245 | """ |
| 246 | |
| 247 | script = tmpdir / "the_script.py" |
| 248 | script.write_text(program_template, encoding="utf-8") |
| 249 | |
| 250 | # WHEN |
| 251 | |
| 252 | threads = generate_threads(python_executable, script, tmpdir) |
| 253 | |
| 254 | # THEN |
| 255 | |
| 256 | assert len(threads) == 1 |
| 257 | (thread,) = threads |
| 258 | |
| 259 | frames = list(thread.frames) |
| 260 | assert (len(frames)) == 3 |
| 261 | |
| 262 | first_func_frame = find_frame(frames, "first_func") |
| 263 | assert "the_local" in first_func_frame.locals |
| 264 | assert eval(first_func_frame.locals["the_local"]) == { |
| 265 | "x": 1, |
| 266 | "y": "barbaridad", |
| 267 | } |
| 268 | |
| 269 | second_func_frame = find_frame(frames, "second_func") |
| 270 | assert "the_argument" in second_func_frame.arguments |
| 271 | assert eval(second_func_frame.arguments["the_argument"]) == { |
| 272 | "x": 1, |
| 273 | "y": "barbaridad", |
| 274 | } |
| 275 | |
| 276 |
nothing calls this directly
no test coverage detected