(pytester: Pytester)
| 547 | |
| 548 | |
| 549 | def test_log_cli_ini_level(pytester: Pytester) -> None: |
| 550 | pytester.makeini( |
| 551 | """ |
| 552 | [pytest] |
| 553 | log_cli=true |
| 554 | log_cli_level = INFO |
| 555 | """ |
| 556 | ) |
| 557 | pytester.makepyfile( |
| 558 | """ |
| 559 | import pytest |
| 560 | import logging |
| 561 | def test_log_cli(request): |
| 562 | plugin = request.config.pluginmanager.getplugin('logging-plugin') |
| 563 | assert plugin.log_cli_handler.level == logging.INFO |
| 564 | logging.getLogger('catchlog').debug("This log message won't be shown") |
| 565 | logging.getLogger('catchlog').info("This log message will be shown") |
| 566 | print('PASSED') |
| 567 | """ |
| 568 | ) |
| 569 | |
| 570 | result = pytester.runpytest("-s") |
| 571 | |
| 572 | # fnmatch_lines does an assertion internally |
| 573 | result.stdout.fnmatch_lines( |
| 574 | [ |
| 575 | "*test_log_cli_ini_level.py* This log message will be shown", |
| 576 | "PASSED", # 'PASSED' on its own line because the log message prints a new line |
| 577 | ] |
| 578 | ) |
| 579 | result.stdout.no_fnmatch_line("*This log message won't be shown*") |
| 580 | |
| 581 | # make sure that we get a '0' exit code for the testsuite |
| 582 | assert result.ret == 0 |
| 583 | |
| 584 | |
| 585 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected