(pytester: Pytester)
| 206 | |
| 207 | |
| 208 | def test_log_cli_default_level(pytester: Pytester) -> None: |
| 209 | # Default log file level |
| 210 | pytester.makepyfile( |
| 211 | """ |
| 212 | import pytest |
| 213 | import logging |
| 214 | def test_log_cli(request): |
| 215 | plugin = request.config.pluginmanager.getplugin('logging-plugin') |
| 216 | assert plugin.log_cli_handler.level == logging.NOTSET |
| 217 | logging.getLogger('catchlog').info("INFO message won't be shown") |
| 218 | logging.getLogger('catchlog').warning("WARNING message will be shown") |
| 219 | """ |
| 220 | ) |
| 221 | pytester.makeini( |
| 222 | """ |
| 223 | [pytest] |
| 224 | log_cli=true |
| 225 | """ |
| 226 | ) |
| 227 | |
| 228 | result = pytester.runpytest() |
| 229 | |
| 230 | # fnmatch_lines does an assertion internally |
| 231 | result.stdout.fnmatch_lines( |
| 232 | [ |
| 233 | "test_log_cli_default_level.py::test_log_cli ", |
| 234 | "WARNING*test_log_cli_default_level.py* message will be shown*", |
| 235 | ] |
| 236 | ) |
| 237 | result.stdout.no_fnmatch_line("*INFO message won't be shown*") |
| 238 | # make sure that we get a '0' exit code for the testsuite |
| 239 | assert result.ret == 0 |
| 240 | |
| 241 | |
| 242 | def test_log_cli_default_level_multiple_tests( |
nothing calls this directly
no test coverage detected