Ran Benita
b47b488e3d
testing: fix flaky test when executed slowly
...
The 0-1 was a bit too optimistic: CI got "no tests ran in 3.98s".
2020-08-23 12:32:30 +03:00
Ran Benita
b1354608cc
logging: fix handler level restored incorrectly if caplog.set_level is called more than once
2020-08-22 17:46:23 +03:00
Ran Benita
b8471aa527
testing: fix some docstring issues
...
In preparation for enforcing some docstring lints.
2020-08-03 10:10:43 +03:00
Ran Benita
0e0275d8d9
logging: fix capture handler level not reset on teardown after caplog.set_level()
...
This probably regressed in fcbaab8
.
2020-07-29 14:59:29 +03:00
Simon K
7f467ebc9a
Create subdirectories if they do not exist when specified for log file ( #7468 )
...
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-11 13:40:28 -03:00
Ruaridh Williamson
304f2916fc
logging: use unique handlers for caplog and reports
...
Setting log_level via the CLI or .ini will control the log level of the
report that is dumped upon failure of a test.
If caplog modified the log level during the execution of that test, it
should not impact the level that is displayed upon failure in the
"captured log report" section.
[
ran:
- rebased
- reused handler
- changed store keys also to "caplog_handler_*"
- added changelog
all bugs are mine :)
]
2020-07-01 19:30:03 +03:00
Bruno Oliveira
fcbaab8b0b
Allow tests to override "global" `log_level` (rebased) ( #7340 )
...
Co-authored-by: Ruaridh Williamson <ruaridh.williamson@flexciton.com>
2020-06-08 22:05:46 -03:00
Ran Benita
54ad048be7
Enable check_untyped_defs mypy option for testing/ too
2020-06-05 11:34:20 +03:00
Ran Benita
b13fcb23d7
logging: propagate errors during log message emits
...
Currently, a bad logging call, e.g.
logger.info('oops', 'first', 2)
triggers the default logging handling, which is printing an error to
stderr but otherwise continuing.
For regular programs this behavior makes sense, a bad log message
shouldn't take down the program. But during tests, it is better not to
skip over such mistakes, but propagate them to the user.
2020-05-19 11:16:39 +03:00
Ran Benita
d2d11a8bdc
logging: reuse LoggingCaptureHandler instance since it's expensive to create
...
Previously, a LoggingCaptureHandler was instantiated for each test's
setup/call/teardown which turns out to be expensive.
Instead, only keep one instance and reset it between runs.
2020-05-18 11:27:50 +03:00
Ran Benita
3f8200676f
logging: remove deprecated --no-print-logs option/ini
...
This option was deprecated in 5.4.0 and was marked for removal in 6.0.0.
2020-05-17 21:41:38 +03:00
Ran Benita
ac6c02f1e2
logging: use item's store for private attributes
...
This makes things type-safe and properly private.
2020-05-17 20:42:05 +03:00
Ran Benita
3cd97d50f9
pre-commit: update pyupgrade 1.18.0 -> 2.2.1
2020-04-24 21:57:38 +03:00
Daniel Hahler
778d4364fa
tests: test_collection_collect_only_live_logging: allow for 1s
...
Might be slow on CI.
Ref: https://github.com/pytest-dev/pytest/pull/6570/checks?check_run_id=408752475#step:6:109
2020-01-25 18:14:49 +01:00
Daniel Hahler
03bc8aba4e
config: typing for create_terminal_writer, re-export TerminalWriter
...
This also imports `TerminalWriter` explicitly via `_pytest._io`,
allowing for easier extending / replacing it.
2020-01-23 14:09:37 +01:00
Daniel Hahler
5049e25a6a
tests: cleanup unused fixtures
2020-01-16 21:12:48 +01:00
Michael Krebs
1f5b454355
Add log-auto-indent option to control multiline formatting
2019-10-25 11:31:33 -04:00
Bruno Oliveira
47c2091ecd
Use new no-match functions to replace previous idiom
2019-10-06 18:05:24 -03:00
Bruno Oliveira
345df99db7
Show session duration in human-readable format
...
Fix #5707
2019-08-10 10:45:53 -03:00
Thomas Hisch
577b0dffe7
Fix verbosity bug in --collect-only
2019-06-05 20:10:16 -03:00
Bruno Oliveira
ce78c9adef
Fix linting
2019-06-03 12:08:50 -03:00
Anthony Sottile
5dcf85c17e
manual: remove dependence on six
2019-06-03 12:08:02 -03:00
Anthony Sottile
c63320cc31
codecs.open / io.open
2019-06-03 12:08:02 -03:00
Anthony Sottile
4df529e5b9
Clean up __future__ and coding: in tests
2019-06-03 12:08:02 -03:00
Anthony Sottile
a91fe1fedd
pre-commit run pyupgrade --all-files
2019-06-03 12:08:02 -03:00
Anthony Sottile
5034399d7a
pre-commit run fix-encoding-pragma --all-files
2019-06-03 12:08:01 -03:00
Thomas Hisch
ef053193b5
logging: Extend LEVELNAME_FMT_REGEX
2019-06-03 05:53:19 +02:00
Thomas Hisch
ea3ebec117
logging: Improve formatting of multiline message
2019-05-29 23:21:14 +02:00
Thomas Hisch
84569ca4da
Merge pull request #5311 from thisch/coloredcaplog
...
Use same code for setting up cli/non-cli formatter
2019-05-29 22:18:43 +02:00
Thomas Hisch
d4b85da8c7
Use same code for setting up cli/non-cli formatter
...
A method _create_formatter was introduced that is used for both the
log_cli_formatter and the log_formatter.
Consequences of this commit are:
* Captured logs that are output for each failing test are formatted
using the ColoredLevelFromatter.
* The formatter used for writing to a file still uses the non-colored
logging.Formatter class.
2019-05-28 21:30:34 +02:00
Anthony Sottile
dc75b6af47
Use fix-encoding-pragma pre-commit hook
2019-05-14 15:56:31 -07:00
Bruno Oliveira
7573747cda
Normalize all source encoding declarations
2019-05-14 19:42:44 -03:00
Pulkit Goyal
7e08e09473
logging: improve default logging format (issue5214)
...
We improve the following things in the logging format:
* Show module name instead of just the filename
* show level of logging as the first thing
* show lineno attached to module:file details
Thanks to @blueyed who suggested this on the github issue.
It's my first contribution and I have added myself to AUTHORS.
I also added to a changelog file.
2019-05-08 21:37:59 +03:00
Daniel Hahler
4148663706
Merge pull request #4979 from blueyed/minor
...
Minor: whitespace, typo, docs
2019-03-26 10:01:13 +01:00
Daniel Hahler
5efe6ab93c
test_log_cli_auto_enable: get stdout once
2019-03-24 11:22:07 +01:00
Daniel Hahler
ce59f42ce1
revisit test_root_logger_affected
2019-03-24 11:21:13 +01:00
Daniel Hahler
7da7b9610c
minor: whitespace
2019-03-24 11:20:24 +01:00
Daniel Hahler
08f3b02dfc
tests: fnmatch_lines: use list
...
For strings fnmatch_lines converts it into a Source objects, splitted on
newlines. This is not necessary here, and it is more consistent to use
lists here in the first place.
2019-03-23 11:36:18 +01:00
Andras Mitzki
b26b731498
Logging: Make pytest_runtest_logreport() available for logging
...
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
2019-02-22 05:14:44 +01:00
Andras Mitzki
e3824d23bc
LoggingPlugin: Expose setting log_file_handler
...
- This patch allows to set log_file (path) from hook
Signed-off-by: Thomas Hisch
Signed-off-by: Andras Mitzki <andras.mitzki@balabit.com>
2019-02-15 16:05:10 +01:00
Daniel Hahler
4a74d455de
minor: typos
2018-11-09 02:03:44 +01:00
Anthony Sottile
2368fbb63c
Apply reorder-python-imports to all files
2018-10-25 00:01:29 -07:00
Vincent Barbaresi
db106d6085
Fix logging usage in hooks pytest_sessionstart/finish #3340
2018-10-20 09:55:10 +02:00
Bruno Oliveira
29d5849519
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2018-10-13 08:50:32 -03:00
Niklas JQ
c14a23d4e4
Fix #4093 : multiple string literals on a line
2018-10-10 19:28:31 +02:00
Bruno Oliveira
9a3836a0cf
Merge remote-tracking branch 'upstream/master' into merge-master-into-features
2018-10-09 19:34:04 -03:00
Anthony Sottile
3901569f26
Improve performance of ~3 of the slowest tests
2018-10-08 11:12:55 -07:00
Thomas Hisch
048342817b
Add testcase for logging to file
2018-09-18 21:47:42 +02:00
Thomas Hisch
e967d4587a
Add support for logging in collection-phase
...
The logging plugin does not output log messages generated during the
collection-phase when live-logging is enabled. This fixes this.
Fixes #3964
2018-09-18 20:18:24 +02:00
victor
7ea4992f16
Fixed linting.
2018-08-19 15:46:02 +02:00