Commit graph

391 commits

Author SHA1 Message Date
Miss Islington (bot)
1ddd2f9036
[3.12] gh-88352: Make TimedRotatingFileHandler tests more stable (GH-116409) (GH-116585)
The tests failed (with less than 1% probability) if for example the file
was created at 11:46:03.999, but the record was emitted at 11:46:04.001,
with atTime=11:46:04, which caused an unexpected rollover. Ensure that the
tests are always run within the range of the same whole second.

Also share code between test_rollover_at_midnight and test_rollover_at_weekday.
(cherry picked from commit d8712fa0c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-11 12:49:30 +02:00
Miss Islington (bot)
3f830adf58
[3.12] gh-115809: Improve TimedRotatingFileHandler.getFilesToDelete() (GH-115812) (GH-116261)
Improve algorithm for computing which rolled-over log files to delete
in logging.TimedRotatingFileHandler. It is now reliable for handlers
without namer and with arbitrary deterministic namer that leaves
the datetime part in the file name unmodified.
(cherry picked from commit 87faec28c7)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-03 07:59:10 +00:00
Miss Islington (bot)
8dae3faab6
[3.12] gh-88352: Fix logging.TimedRotatingFileHandler (GH-116191) (GH-116208)
* Do not overwrite already rolled over files. It happened at midnight or
  during the DST change and caused the loss of data.
* computeRollover() now always return the timestamp larger than the
  specified time.
* Fix computation of the rollover time during the DST change.
(cherry picked from commit fee86fd9a4)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-03-01 18:41:30 +02:00
Miss Islington (bot)
3651c2729a
[3.12] gh-93205: When rotating logs with no namer specified, match whole extension (GH-93224) (GH-115784)
(cherry picked from commit 113687a838)

Co-authored-by: Gabriele Catania <gabriele.ctn@gmail.com>
2024-02-21 21:36:25 +00:00
Serhiy Storchaka
225856ef3e
[3.12] gh-115233: Fix an example in the Logging Cookbook (GH-115325) (GH-115355)
Also add more tests for LoggerAdapter.

Also support stacklevel in LoggerAdapter._log().
(cherry picked from commit 91822018ee)
2024-02-12 18:29:48 +00:00
Miss Islington (bot)
58fdd15d5a
[3.12] gh-108303: Move smtpd to test.support (GH-114368) (#114427)
gh-108303: Move `smtpd` to `test.support` (GH-114368)

Update test_logging.py and test_smtplib.py.
(cherry picked from commit 8f5e7d739f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-01-22 14:08:31 +00:00
Miss Islington (bot)
cdd703d131
[3.12] gh-113692: skip a test if multiprocessing isn't available. (GH-113704) (GH-113844)
(cherry picked from commit 842b738129)
2024-01-09 08:13:41 +00:00
Miss Islington (bot)
ba3e19a5d7
[3.12] gh-111615: Fix regression in QueueHandler configuration. (GH-111638) (GH-113507) 2023-12-27 14:20:36 +00:00
Miss Islington (bot)
09df271965
[3.12] gh-110875: Handle '.' properties in logging formatter configuration c… (GH-110943) (GH-111911)
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2023-11-09 19:34:10 +00:00
Miss Islington (bot)
55448a5b14
[3.12] gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657) (#110664)
gh-110656: Fix logging test_post_fork_child_no_deadlock() if ASAN (GH-110657)

Skip test_post_fork_child_no_deadlock() if Python is built with ASAN.

Add support.HAVE_ASAN_FORK_BUG.
(cherry picked from commit f901f56313)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-10-11 01:31:49 +00:00
Miss Islington (bot)
c2d542b42c
[3.12] gh-108303: Move all certificates to Lib/test/certdata/ (GH-109489) (#109682)
* gh-108303: Move all certificates to `Lib/test/certdata/` (GH-109489)
(cherry picked from commit e57ecf6bbc)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Python 3.12 backport: update also `test_nntplib`.

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: T. Wouters <thomas@python.org>
2023-10-10 22:38:18 +02:00
Victor Stinner
0855b2c8b6
[3.12] gh-108834: Sync libregrtest with the main branch (#108966)
* gh-108834: regrtest reruns failed tests in subprocesses (#108839)

When using --rerun option, regrtest now re-runs failed tests
in verbose mode in fresh worker processes to have more
deterministic behavior. So it can write its final report even
if a test killed a worker progress.

Add --fail-rerun option to regrtest: exit with non-zero exit code
if a test failed pass passed when re-run in verbose mode (in a
fresh process). That's now more useful since tests can pass
when re-run in a fresh worker progress, whereas they failed
when run after other tests when tests are run sequentially.

Rename --verbose2 option (-w) to --rerun. Keep --verbose2 as a
deprecated alias.

Changes:

* Fix and enhance statistics in regrtest summary. Add "(filtered)"
  when --match and/or --ignore options are used.
* Add RunTests class.
* Add TestResult.get_rerun_match_tests() method
* Rewrite code to serialize/deserialize worker arguments as JSON
  using a new WorkerJob class.
* Fix stats when a test is run with --forever --rerun.
* If failed test names cannot be parsed, log a warning and don't
  filter tests.
* test_regrtest.test_rerun_success() now uses a marker file, since
  the test is re-run in a separated process.
* Add tests on normalize_test_name() function.
* Add test_success() and test_skip() tests to test_regrtest.

(cherry picked from commit 31c2945f14)

* gh-108834: regrtest --fail-rerun exits with code 5 (#108896)

When the --fail-rerun option is used and a test fails and then pass,
regrtest now uses exit code 5 ("rerun) instead of 2 ("bad test").

(cherry picked from commit 1170d5a292)

* gh-108416: Mark slow but not CPU bound test methods with requires_resource('walltime') (GH-108480)

(cherry picked from commit 1e0d62793a)

* Manually sync Lib/test/libregrtest/ from main

---------

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-09-08 15:14:17 +02:00
Miss Islington (bot)
e788c0aeeb
[3.12] gh-107237: Fix test_udp_reconnection() of test_logging (GH-107238) (#107242)
gh-107237: Fix test_udp_reconnection() of test_logging (GH-107238)

test_logging: Fix test_udp_reconnection() by increasing the timeout
from 100 ms to 5 minutes (LONG_TIMEOUT).

Replace also blocking wait() with wait(LONG_TIMEOUT) in
test_output() to prevent the test to hang.
(cherry picked from commit ed08238327)

Co-authored-by: Victor Stinner <vstinner@python.org>
2023-07-25 13:43:11 +00:00
Prince Roshan
12f1581b0c
gh-103606: raise RuntimeError if config file is invalid or empty (#104701)
(this adjusts new code) raise RuntimeError if provided config file is invalid or empty, not ValueError.
2023-05-20 22:26:49 +00:00
Prince Roshan
152227b569
gh-103606: Improve error message from logging.config.FileConfig (GH-103628) 2023-05-18 05:20:47 +01:00
Bar Harel
8f54302ab4
gh-103357: Add logging.Formatter defaults support to logging.config fileConfig and dictConfig (GH-103359) 2023-04-12 08:35:56 +01:00
Irit Katriel
482b6eeadc
gh-102799: use sys.exception() instead of sys.exc_info() in tests (#103293) 2023-04-06 11:08:25 +01:00
Gregory P. Smith
d4c410f0f9
gh-84559: Remove the new multiprocessing warning, too disruptive. (#101551)
This reverts the core of #100618 while leaving relevant documentation
improvements and minor refactorings in place.
2023-02-03 15:20:46 -08:00
Gregory P. Smith
0ca67e6313
GH-84559: Deprecate fork being the multiprocessing default. (#100618)
This starts the process. Users who don't specify their own start method
and use the default on platforms where it is 'fork' will see a
DeprecationWarning upon multiprocessing.Pool() construction or upon
multiprocessing.Process.start() or concurrent.futures.ProcessPool use.

See the related issue and documentation within this change for details.
2023-02-02 15:50:35 -08:00
Nikita Sobolev
e56e33d271
gh-72719: Remove asyncore and asynchat modules (#96580)
Remove modules asyncore and asynchat, which were deprecated by PEP 594.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-11-08 16:48:58 +01:00
Vinay Sajip
ac4ddab405
gh-90195: Unset logger disabled flag when configuring it. (GH-96530) 2022-09-03 13:38:38 +01:00
Vinay Sajip
29f1b0bb1f
gh-89258: Add a getChildren() method to logging.Logger. (GH-96444)
Co-authored-by: Éric <merwok@netwok.org>
2022-08-31 10:50:29 +01:00
Vinay Sajip
6fbd889d6e
gh-89047: Fix msecs computation so you never end up with 1000 msecs. (GH-96340) 2022-08-27 13:33:24 +01:00
David Bonner
37c0f9ccc0
gh-95804: Respect MemoryHandler.flushOnClose in logging shutdown. (GH-95857) 2022-08-10 18:08:55 +01:00
Oleg Iarygin
56d16e8cb4
gh-93243: Make smtpd private before porting its users (GH-93246)
gh-93243

This PR is required to reduce diffs of the following porting (no need to either maintain documentation and tests consistent with each porting step, or try to port everything and remove smtpd in a single PR).

Automerge-Triggered-By: GH:warsaw
2022-08-05 17:41:29 -07:00
Erik Montnemery
c60f125533
bpo-46755: Don't log stack info twice in QueueHandler (GH-31355) 2022-07-05 15:23:12 +01:00
Victor Stinner
dba3fa57e2
gh-93761: Fix test_logging test_config_queue_handler() race condition (#93952)
Fix a race condition in test_config_queue_handler() of test_logging.
2022-06-19 11:49:35 +02:00
Victor Stinner
c5b750dc0b
gh-93852: Add test.support.create_unix_domain_name() (#93914)
test_asyncio, test_logging, test_socket and test_socketserver now
create AF_UNIX domains in the current directory to no longer fail
with OSError("AF_UNIX path too long") if the temporary directory (the
TMPDIR environment variable) is too long.

Modify the following tests to use create_unix_domain_name():

* test_asyncio
* test_logging
* test_socket
* test_socketserver

test_asyncio.utils: remove unused time import.
2022-06-17 13:16:51 +02:00
Victor Stinner
538f28921f
test_logging: Fix BytesWarning in SysLogHandlerTest (GH-93920) 2022-06-17 09:09:54 +01:00
Victor Stinner
484b40bf18
Call busy_retry() and sleeping_retry() with error=True (#93871)
Tests no longer call busy_retry() and sleeping_retry() with
error=False: raise an exception if the loop times out.
2022-06-16 13:44:58 +02:00
Victor Stinner
0ba80273f2
Use support.sleeping_retry() and support.busy_retry() (#93848)
* Replace time.sleep(0.010) with sleeping_retry() to
  use an exponential sleep.
* support.wait_process(): reuse sleeping_retry().
* _test_eintr: remove unused variables.
2022-06-15 14:09:56 +02:00
Vinay Sajip
5bcf33de0b
gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779) 2022-06-14 06:41:16 +01:00
Adrian Garcia Badaracco
296081a7ce
gh-92592: Allow logging filters to return a LogRecord. (GH-92591) 2022-06-07 16:53:57 +01:00
Christian Heimes
cdb73aefec
gh-93162: test_config_queue_handler requires threading (GH-93572) 2022-06-07 12:34:08 +02:00
Vinay Sajip
1b74803991
gh-93162: Add ability to configure QueueHandler/QueueListener together (GH-93269)
Also, provide getHandlerByName() and getHandlerNames() APIs.

Closes #93162.
2022-06-07 10:20:35 +02:00
Christian Heimes
af5bb1fba4
gh-84461: Skip new async logging tests on Emscripten (GH-93427) 2022-06-02 09:35:06 +02:00
Vinay Sajip
efc5d37671
gh-91513: Tidied up a test and did minor refactoring around test filename gener… (GH-93265) 2022-05-26 17:11:15 +01:00
jackh-ncl
cc377063ef
gh-91513: Add 'asyncio' taskName to logging LogRecord attributes. (GH-93193) 2022-05-26 09:30:51 +01:00
Christian Heimes
137fd3d88a
gh-90473: Decrease recursion limit and skip tests on WASI (GH-92803) 2022-05-19 12:43:16 +02:00
Serhiy Storchaka
086c6b1b0f
bpo-45046: Support context managers in unittest (GH-28045)
Add methods enterContext() and enterClassContext() in TestCase.
Add method enterAsyncContext() in IsolatedAsyncioTestCase.
Add function enterModuleContext().
2022-05-08 17:49:09 +03:00
Hugo van Kemenade
9b027d4cea
gh-92169: Use warnings_helper.import_deprecated() to import deprecated modules uniformly in tests (GH-92170) 2022-05-03 10:17:54 +03:00
Christian Heimes
2b16a08bc7
bpo-40280: Detect missing threading on WASM platforms (GH-32352)
Co-authored-by: Brett Cannon <brett@python.org>
2022-04-07 09:22:47 +02:00
Jouke Witteveen
c12ba6b2ff
bpo-45171: Remove tests of deprecated logger.warn(). (GH-32139) 2022-03-27 19:22:05 +01:00
Jouke Witteveen
5ca6d7469b
bpo-45171: Fix stacklevel handling in logging. (GH-28287) 2022-03-27 14:49:28 +01:00
Christian Heimes
deeaac49e2
bpo-40280: Skip socket, fork, subprocess tests on Emscripten (GH-31986)
- Add requires_fork and requires_subprocess to more tests
- Skip extension import tests if dlopen is not available
- Don't assume that _testcapi is a shared extension
- Skip a lot of socket tests that don't work on Emscripten
- Skip mmap tests, mmap emulation is incomplete
- venv does not work yet
- Cannot get libc from executable

The "entire" test suite is now passing on Emscripten with EMSDK from git head (91 suites are skipped).
2022-03-22 03:04:36 -07:00
Christian Heimes
ef1327e3b6
bpo-40280: Skip more tests on Emscripten (GH-31947)
- lchmod, lchown are not fully implemented
- skip umask tests
- cannot fstat unlinked or renamed files yet
- ignore musl libc issues that affect Emscripten
2022-03-17 12:09:57 +01:00
Mario Corchero
d7c6863979
bpo-41906: Accept built filters in dictConfig (GH-30756)
When configuring the logging stack, accept already built filters (or
just callables) in the filters array of loggers and handlers.
This facilitates passing quick callables as filters.

Automerge-Triggered-By: GH:vsajip
2022-01-24 04:39:50 -08:00
Irit Katriel
a287b31bcb
bpo-46411: Remove unnecessary calls to sys.exc_info() in tests (GH-30638) 2022-01-18 07:05:16 +00:00
Vinay Sajip
850aefc2c6
bpo-46063: Add 'delay=True' to file handler initialization. (GH-30103) 2021-12-14 16:46:07 +00:00
Vinay Sajip
cb589d1b6b
bpo-46063: Improve algorithm for computing which rolled-over log file… (GH-30093) 2021-12-14 00:53:37 +00:00