(generate_threads, python, tmpdir)
| 394 | @ALL_PYTHONS |
| 395 | @ALL_SOURCES |
| 396 | def test_custom_object(generate_threads, python, tmpdir): |
| 397 | # GIVEN |
| 398 | _, python_executable = python |
| 399 | |
| 400 | program_template = """ |
| 401 | import sys |
| 402 | import time |
| 403 | |
| 404 | class A: |
| 405 | pass |
| 406 | |
| 407 | def first_func(): |
| 408 | the_local = A() |
| 409 | second_func(the_local) |
| 410 | |
| 411 | def second_func(the_argument): |
| 412 | fifo = sys.argv[1] |
| 413 | with open(sys.argv[1], "w") as fifo: |
| 414 | fifo.write("ready") |
| 415 | time.sleep(1000) |
| 416 | |
| 417 | first_func() |
| 418 | """ |
| 419 | |
| 420 | script = tmpdir / "the_script.py" |
| 421 | script.write_text(program_template, encoding="utf-8") |
| 422 | |
| 423 | # WHEN |
| 424 | |
| 425 | threads = generate_threads(python_executable, script, tmpdir) |
| 426 | |
| 427 | # THEN |
| 428 | |
| 429 | assert len(threads) == 1 |
| 430 | (thread,) = threads |
| 431 | |
| 432 | frames = list(thread.frames) |
| 433 | assert (len(frames)) == 3 |
| 434 | |
| 435 | repr_regex = re.compile(r"<(?:A|instance|\?\?\?) at 0[xX][0-9a-fA-F]+>") |
| 436 | |
| 437 | first_func_frame = find_frame(frames, "first_func") |
| 438 | assert "the_local" in first_func_frame.locals |
| 439 | argument_repr = first_func_frame.locals["the_local"] |
| 440 | assert repr_regex.match(argument_repr) |
| 441 | |
| 442 | second_func_frame = find_frame(frames, "second_func") |
| 443 | assert "the_argument" in second_func_frame.arguments |
| 444 | argument_repr = second_func_frame.arguments["the_argument"] |
| 445 | assert repr_regex.match(argument_repr) |
| 446 | |
| 447 | |
| 448 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected