(generate_threads, python, tmpdir)
| 121 | @ALL_PYTHONS |
| 122 | @ALL_SOURCES |
| 123 | def test_bytes(generate_threads, python, tmpdir): |
| 124 | # GIVEN |
| 125 | _, python_executable = python |
| 126 | |
| 127 | program_template = """ |
| 128 | import sys |
| 129 | import time |
| 130 | |
| 131 | |
| 132 | def first_func(): |
| 133 | the_local = b"Hello world" |
| 134 | second_func(the_local) |
| 135 | |
| 136 | def 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 | |
| 142 | first_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 |
nothing calls this directly
no test coverage detected