(pytester: Pytester, method: str)
| 1376 | "method", ["SysCapture(2)", "SysCapture(2, tee=True)", "FDCapture(2)"] |
| 1377 | ) |
| 1378 | def test_capturing_and_logging_fundamentals(pytester: Pytester, method: str) -> None: |
| 1379 | # here we check a fundamental feature |
| 1380 | p = pytester.makepyfile( |
| 1381 | """ |
| 1382 | import sys, os, logging |
| 1383 | from _pytest import capture |
| 1384 | cap = capture.MultiCapture( |
| 1385 | in_=None, |
| 1386 | out=None, |
| 1387 | err=capture.%s, |
| 1388 | ) |
| 1389 | cap.start_capturing() |
| 1390 | |
| 1391 | logging.warning("hello1") |
| 1392 | outerr = cap.readouterr() |
| 1393 | print("suspend, captured %%s" %%(outerr,)) |
| 1394 | logging.warning("hello2") |
| 1395 | |
| 1396 | cap.pop_outerr_to_orig() |
| 1397 | logging.warning("hello3") |
| 1398 | |
| 1399 | outerr = cap.readouterr() |
| 1400 | print("suspend2, captured %%s" %% (outerr,)) |
| 1401 | """ |
| 1402 | % (method,) |
| 1403 | ) |
| 1404 | result = pytester.runpython(p) |
| 1405 | result.stdout.fnmatch_lines( |
| 1406 | """ |
| 1407 | suspend, captured*hello1* |
| 1408 | suspend2, captured*WARNING:root:hello3* |
| 1409 | """ |
| 1410 | ) |
| 1411 | result.stderr.fnmatch_lines( |
| 1412 | """ |
| 1413 | WARNING:root:hello2 |
| 1414 | """ |
| 1415 | ) |
| 1416 | assert "atexit" not in result.stderr.str() |
| 1417 | |
| 1418 | |
| 1419 | def test_error_attribute_issue555(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected