Create a pytest fixture to run the example in pty subprocess & cleanup. :param example: relative path like 'examples/input.py' :return: pytest fixture
(example)
| 244 | |
| 245 | |
| 246 | def create_example_fixture(example): |
| 247 | """Create a pytest fixture to run the example in pty subprocess & cleanup. |
| 248 | |
| 249 | :param example: relative path like 'examples/input.py' |
| 250 | :return: pytest fixture |
| 251 | """ |
| 252 | @pytest.fixture |
| 253 | def example_app(): |
| 254 | p = SimplePty.spawn(['python', example]) |
| 255 | yield p |
| 256 | # it takes some time to collect the coverage data |
| 257 | # if the main process exits too early the coverage data is not available |
| 258 | time.sleep(p.delayafterterminate) |
| 259 | p.sendintr() # in case the subprocess was not ended by the test |
| 260 | p.wait() # without wait() the coverage info never arrives |
| 261 | return example_app |
no outgoing calls
no test coverage detected
searching dependent graphs…