(pytester: Pytester)
| 497 | |
| 498 | |
| 499 | def test_log_cli_level(pytester: Pytester) -> None: |
| 500 | # Default log file level |
| 501 | pytester.makepyfile( |
| 502 | """ |
| 503 | import pytest |
| 504 | import logging |
| 505 | def test_log_cli(request): |
| 506 | plugin = request.config.pluginmanager.getplugin('logging-plugin') |
| 507 | assert plugin.log_cli_handler.level == logging.INFO |
| 508 | logging.getLogger('catchlog').debug("This log message won't be shown") |
| 509 | logging.getLogger('catchlog').info("This log message will be shown") |
| 510 | print('PASSED') |
| 511 | """ |
| 512 | ) |
| 513 | pytester.makeini( |
| 514 | """ |
| 515 | [pytest] |
| 516 | log_cli=true |
| 517 | """ |
| 518 | ) |
| 519 | |
| 520 | result = pytester.runpytest("-s", "--log-cli-level=INFO") |
| 521 | |
| 522 | # fnmatch_lines does an assertion internally |
| 523 | result.stdout.fnmatch_lines( |
| 524 | [ |
| 525 | "*test_log_cli_level.py*This log message will be shown", |
| 526 | "PASSED", # 'PASSED' on its own line because the log message prints a new line |
| 527 | ] |
| 528 | ) |
| 529 | result.stdout.no_fnmatch_line("*This log message won't be shown*") |
| 530 | |
| 531 | # make sure that we get a '0' exit code for the testsuite |
| 532 | assert result.ret == 0 |
| 533 | |
| 534 | result = pytester.runpytest("-s", "--log-level=INFO") |
| 535 | |
| 536 | # fnmatch_lines does an assertion internally |
| 537 | result.stdout.fnmatch_lines( |
| 538 | [ |
| 539 | "*test_log_cli_level.py* This log message will be shown", |
| 540 | "PASSED", # 'PASSED' on its own line because the log message prints a new line |
| 541 | ] |
| 542 | ) |
| 543 | result.stdout.no_fnmatch_line("*This log message won't be shown*") |
| 544 | |
| 545 | # make sure that we get a '0' exit code for the testsuite |
| 546 | assert result.ret == 0 |
| 547 | |
| 548 | |
| 549 | def test_log_cli_ini_level(pytester: Pytester) -> None: |
nothing calls this directly
no test coverage detected