Commit Graph

343 Commits

Author SHA1 Message Date
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
Victor Stinner cf7eaa4617
Revert "bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)" (GH-29951)
This reverts commit 9bf2cbc4c4.
2021-12-07 12:31:04 +01:00
Victor Stinner 9bf2cbc4c4
bpo-28533: Remove asyncore, asynchat, smtpd modules (GH-29521)
Remove the asyncore and asynchat modules, deprecated in Python
3.6: use the asyncio module instead.

Remove the smtpd module, deprecated in Python 3.6: the aiosmtpd
module can be used instead, it is based on asyncio.

* Remove asyncore, asynchat and smtpd documentation
* Remove test_asyncore, test_asynchat and test_smtpd
* Rename Lib/asynchat.py to Lib/test/support/_asynchat.py
* Rename Lib/asyncore.py to Lib/test/support/_asyncore.py
* Rename Lib/smtpd.py to Lib/test/support/_smtpd.py
* Remove DeprecationWarning from private _asyncore, _asynchat and
  _smtpd modules
* _smtpd: remove deprecated properties
2021-11-16 00:29:17 +01:00
Serhiy Storchaka 15188b115a
bpo-45401: Fix a resource warning in test_logging (GH-28864) 2021-10-11 11:54:44 +03:00
Vinay Sajip 62a667784b
bpo-45401: Change shouldRollover() methods to only rollover regular f… (GH-28822)
…iles.

Also changed some historical return values from 1 -> True and 0 -> False.
2021-10-10 08:15:24 -07:00
Nikita Sobolev 1d42408495
bpo-45128: fixes `test_multiprocessing_fork` mysterious crash (GH-28387) 2021-09-19 23:50:04 +01:00
Serhiy Storchaka 40348acc18
bpo-45229: Remove test_main in many tests (GH-28405)
Instead of explicitly enumerate test classes for run_unittest()
use the unittest ability to discover tests. This also makes these
tests discoverable and runnable with unittest.

load_tests() can be used for dynamic generating tests and adding
doctests. setUpModule(), tearDownModule() and addModuleCleanup()
can be used for running code before and after all module tests.
2021-09-19 15:27:33 +03:00
Kirill Pinchuk 3d315c3116
bpo-44291: Fix reconnection in logging.handlers.SysLogHandler (GH-26490) 2021-08-05 14:58:16 +01:00
Mariusz Felisiak 11749e2dc2
bpo-44740: Lowercase "internet" and "web" where appropriate. (#27378)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-27 00:11:55 +02:00
andrei kulakov 96cf5a63d2
bpo-42378: fixed log truncation on logging shutdown (GH-27310)
Automerge-Triggered-By: GH:vsajip
2021-07-25 13:17:47 -07:00
Irit Katriel 22e7effad5
bpo-44498: suppress DeprecationWarnings for asynchat, asyncore and smtpd in tests (GH-26905) 2021-06-25 00:20:40 +01:00
andrei kulakov 8b93f0e696
bpo-43858: Add logging.getLevelNamesMapping() (GH-26459)
Added a function that returns a copy of a dict of logging levels.
2021-06-03 01:12:59 -07:00
Inada Naoki 53dd6c99b3
bpo-43651: Fix test_logging (GH-25715) 2021-04-29 20:37:32 +09:00
Inada Naoki fa51c0c448
bpo-43651: Fix EncodingWarning in tests. (GH-25655)
* test_httplib
* test_httpservers
* test_logging
2021-04-29 11:34:56 +09:00
Victor Stinner fe52eb6219
bpo-43961: Fix test_logging.test_namer_rotator_inheritance() (GH-25684)
Fix test_logging.test_namer_rotator_inheritance() on Windows: use
os.replace() rather than os.rename().
2021-04-28 15:47:10 +02:00
Victor Stinner 75ec103b3a
bpo-43842: Fix race condition in test_logging SMTP test (GH-25436)
Fix a race condition in the SMTP test of test_logging. Don't close a
file descriptor (socket) from a different thread while
asyncore.loop() is polling the file descriptor.
2021-04-16 14:32:01 +02:00
Christian Heimes 95bbb331ec
bpo-43723: Fix deprecation error caused by thread.setDaemon() (GH-25361) 2021-04-12 13:12:36 +02:00
Inada Naoki fb78692f2a
bpo-43651: PEP 597: Fix EncodingWarning in some tests (GH-25189)
* Fix _sitebuiltins
* Fix test_inspect
* Fix test_interpreters
* Fix test_io
* Fix test_iter
* Fix test_json
* Fix test_linecache
* Fix test_lltrace
* Fix test_logging
* Fix logging
2021-04-06 11:18:41 +09:00
Matthias Bussonnier b32d8b4f9b
bpo-42644: Validate values in logging.disable() (#23786)
* bpo-42644: Validate values in logging.disable()

Technically make the value of manager a property that checks and convert
values assigned to it properly. This has the side effect of making
`logging.disable` also accept strings representing the various level of
warnings.

We want to validate the type of the disable attribute at assignment
time, as it is later compared to other levels when emitting warnings and
would generate a `TypeError: '>=' not supported between ....` in a
different part of the code base, which can make it difficult to track
down.

When assigned an incorrect value; it will raise a TypeError when the
wrong type, or ValueError if an invalid str.

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2020-12-16 11:43:39 +02:00
Victor Stinner 45df61fd2d
bpo-26789: Fix logging.FileHandler._open() at exit (GH-23053)
The logging.FileHandler class now keeps a reference to the builtin
open() function to be able to open or reopen the file during Python
finalization.

Fix errors like:

    Exception ignored in: (...)
    Traceback (most recent call last):
      (...)
      File ".../logging/__init__.py", line 1463, in error
      File ".../logging/__init__.py", line 1577, in _log
      File ".../logging/__init__.py", line 1587, in handle
      File ".../logging/__init__.py", line 1649, in callHandlers
      File ".../logging/__init__.py", line 948, in handle
      File ".../logging/__init__.py", line 1182, in emit
      File ".../logging/__init__.py", line 1171, in _open
    NameError: name 'open' is not defined
2020-11-02 23:17:46 +01:00
Victor Stinner 13ff396c01
bpo-41739: Fix test_logging.test_race_between_set_target_and_flush() (GH-22655)
The test now waits until all threads complete to avoid leaking
running threads.

Also, use regular threads rather than daemon threads.
2020-10-12 00:37:20 +02:00
Eric Larson 9fdb76c34c
Fix logging error message (GH-22410)
Same changes as #22276 squashed to a single commit. Just hoping to get Travis to cooperate by opening a new PR...

Automerge-Triggered-By: @vsajip
2020-09-25 11:08:50 -07:00
Irit Katriel 3fd69991f4
bpo-38762: Extend logging.test_multiprocessing to cover missing cases. (GH-22142) 2020-09-08 20:40:04 +01:00
Victor Stinner fbf43f051e
bpo-41521: Rename blacklist parameter to not_exported (GH-21824)
Rename "blacklist" parameter of test.support.check__all__() to
"not_exported".
2020-08-17 07:20:40 +02:00
Irit Katriel 2353d77fad
bpo-41503: Fix race between setTarget and flush in logging.handlers.MemoryHandler (GH-21765) 2020-08-16 16:10:13 +01:00
Hai Shi 3ddc634cd5
bpo-40275: Use new test.support helper submodules in tests (GH-21219) 2020-06-30 15:46:06 +02:00
Bar Harel 8f192d12af
bpo-40884: Added defaults parameter for logging.Formatter (GH-20668)
Docs and tests are underway.

Automerge-Triggered-By: @vsajip
2020-06-18 07:18:58 -07:00
Victor Stinner ddbeb2f3e0
bpo-38377: Add support.skip_if_broken_multiprocessing_synchronize() (GH-20944)
On Linux, skip tests using multiprocessing if the current user cannot
create a file in /dev/shm/ directory. Add the
skip_if_broken_multiprocessing_synchronize() function to the
test.support module.
2020-06-18 14:53:19 +02:00
Hai Shi e80697d687
bpo-40275: Adding threading_helper submodule in test.support (GH-20263) 2020-05-28 00:10:27 +02:00
Hai Shi a3ec3ad9e2
bpo-40275: More lazy imports in test.support (GH-20131)
Make the the following imports lazy in test.support:

* bz2
* gzip
* lzma
* resource
* zlib

The following test.support decorators now need to be called
with parenthesis:

* @support.requires_bz2
* @support.requires_gzip
* @support.requires_lzma
* @support.requires_zlib

For example, "@requires_zlib" becomes "@requires_zlib()".
2020-05-19 00:02:57 +02:00
Victor Stinner b1e11c31c5
bpo-40443: Remove unused imports in tests (GH-19804) 2020-04-30 02:21:30 +02:00
Serhiy Storchaka 515fce4fc4
bpo-40275: Avoid importing logging in test.support (GH-19601)
Import logging lazily in assertLogs() in unittest.
Move TestHandler from test.support to logging_helper.
2020-04-25 11:35:18 +03:00
Serhiy Storchaka 16994912c9
bpo-40275: Avoid importing socket in test.support (GH-19603)
* Move socket related functions from test.support to socket_helper.
* Import socket, nntplib and urllib.error lazily in transient_internet().
* Remove importing multiprocess.
2020-04-25 10:06:29 +03:00
Mariusz Felisiak 06a35542aa
bpo-40300: Allow empty logging.Formatter.default_msec_format. (GH-19551) 2020-04-17 17:02:47 +01:00
Victor Stinner 278c1e159c
bpo-40094: Add test.support.wait_process() (GH-19254)
Moreover, the following tests now check the child process exit code:

* test_os.PtyTests
* test_mailbox.test_lock_conflict()
* test_tempfile.test_process_awareness()
* test_uuid.testIssue8621()
* multiprocessing resource tracker tests
2020-03-31 20:08:12 +02:00
Victor Stinner c6e5c1123b
bpo-39489: Remove COUNT_ALLOCS special build (GH-18259)
Remove:

* COUNT_ALLOCS macro
* sys.getcounts() function
* SHOW_ALLOC_COUNT code in listobject.c
* SHOW_TRACK_COUNT code in tupleobject.c
* PyConfig.show_alloc_count field
* -X showalloccount command line option
* @test.support.requires_type_collecting decorator
2020-02-03 15:17:15 +01:00
Vinay Sajip 46abfc1416
bpo-39142: Avoid converting namedtuple instances to ConvertingTuple. (GH-17773)
This uses the heuristic of assuming a named tuple is a subclass of
tuple with a _fields attribute. This change means that contents of
a named tuple wouldn't be converted - if a user wants to have
ConvertingTuple functionality from a namedtuple, they will have to
implement it themselves.
2020-01-01 19:32:11 +00:00
Victor Stinner c98b0199a9
bpo-38614: Use test.support.LONG_TIMEOUT constant (GH-17562)
Replace hardcoded timeout constants in tests with LONG_TIMEOUT of
test.support, so it's easier to ajdust this timeout for all tests at
once.

LONG_TIMEOUT is 5 minutes by default, but it can be longer depending
on --timeout command line option.
2019-12-10 21:12:26 +01:00
Victor Stinner bbc8b7965b
bpo-38614: Use default join_thread() timeout in tests (GH-17559)
Tests no longer pass a timeout value to join_thread() of
test.support: use the default join_thread() timeout instead
(SHORT_TIMEOUT constant of test.support).
2019-12-10 20:41:23 +01:00
l0rb 991b02dc87 update a deprecated assert in logging tests (GH-17079) 2019-11-07 10:13:36 +00:00
l0rb 519cb8772a bpo-38716: stop rotating handlers from setting inherited namer and rotator to None (GH-17072) 2019-11-06 21:21:40 +00:00
Lucas Cimon b15100fe7d bpo-38586: setting logging.Handler .name property in fileConfig (GH-16918) 2019-10-31 08:06:25 +00:00
Vinay Sajip 1d094af716
Updated incorrect level-setting code to use setLevel(). (GH-16325) 2019-09-22 03:51:51 +01:00
Vinay Sajip cb65b3a4f4
bpo-37742: Return the root logger when logging.getLogger('root') is c… (#15077)
* bpo-37742: Return the root logger when logging.getLogger('root') is called.

* Added type check guard on logger name in logging.getLogger() and refined a test.
2019-08-02 16:53:00 +01:00
Vinay Sajip 0150001653
bpo-37258: Not a bug, but added a unit test and updated documentation. (GH-14229) 2019-06-19 11:46:53 +01:00
Vinay Sajip ca7b504a4d
bpo-37111: Add 'encoding' and 'errors' parameters to logging.basicCon… (GH-14008) 2019-06-17 17:40:52 +01:00
Bar Harel 6b282e1887 bpo-36813: Fix QueueListener to call task_done() upon termination. (GH-13113)
Fixed QueueListener in order to avoid random deadlocks.
Unable to add regression tests atm due to time constraints, will add it in a bit.
Regarding implementation, although it's nested, it does not cause performance issues whatsoever, and does not call task_done() in case of an exception (which is the right thing to do IMHO).


https://bugs.python.org/issue36813
2019-06-01 02:19:09 -07:00
Xtreak 2c10538d11 bpo-36903: Fix ResourceWarning in test_logging (GH-13283) 2019-05-13 16:48:51 +02:00
Riccardo Magliocchetti ca87eebb22 bpo-36015: Handle StreamHandler representaton of stream with an integer name (GH-11908) 2019-05-07 22:36:39 +01:00