2022-06-07 05:20:35 -03:00
|
|
|
# Copyright 2001-2022 by Vinay Sajip. All Rights Reserved.
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and distribute this software and its
|
|
|
|
# documentation for any purpose and without fee is hereby granted,
|
|
|
|
# provided that the above copyright notice appear in all copies and that
|
|
|
|
# both that copyright notice and this permission notice appear in
|
|
|
|
# supporting documentation, and that the name of Vinay Sajip
|
|
|
|
# not be used in advertising or publicity pertaining to distribution
|
|
|
|
# of the software without specific, written prior permission.
|
|
|
|
# VINAY SAJIP DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
# ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
|
|
|
# VINAY SAJIP BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
# ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
|
|
|
# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
|
|
|
|
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
"""Test harness for the logging module. Run all tests.
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
Copyright (C) 2001-2022 Vinay Sajip. All Rights Reserved.
|
2003-01-02 10:56:39 -04:00
|
|
|
"""
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import logging
|
|
|
|
import logging.handlers
|
|
|
|
import logging.config
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
import codecs
|
2012-10-09 05:06:03 -03:00
|
|
|
import configparser
|
2018-10-16 11:17:57 -03:00
|
|
|
import copy
|
2010-09-17 15:57:36 -03:00
|
|
|
import datetime
|
2016-09-07 21:37:03 -03:00
|
|
|
import pathlib
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import pickle
|
|
|
|
import io
|
2022-06-07 05:20:35 -03:00
|
|
|
import itertools
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import gc
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
import json
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import os
|
2010-09-14 06:34:09 -03:00
|
|
|
import queue
|
2012-04-24 19:25:30 -03:00
|
|
|
import random
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import re
|
2021-12-13 20:53:37 -04:00
|
|
|
import shutil
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import socket
|
|
|
|
import struct
|
|
|
|
import sys
|
|
|
|
import tempfile
|
2019-03-15 03:53:34 -03:00
|
|
|
from test.support.script_helper import assert_python_ok, assert_python_failure
|
2014-05-31 04:19:12 -03:00
|
|
|
from test import support
|
2024-01-09 03:47:42 -04:00
|
|
|
from test.support import import_helper
|
2020-06-30 10:46:06 -03:00
|
|
|
from test.support import os_helper
|
2020-04-25 04:06:29 -03:00
|
|
|
from test.support import socket_helper
|
2020-05-27 19:10:27 -03:00
|
|
|
from test.support import threading_helper
|
2020-06-30 10:46:06 -03:00
|
|
|
from test.support import warnings_helper
|
2022-11-08 11:48:58 -04:00
|
|
|
from test.support import asyncore
|
2024-01-22 09:36:29 -04:00
|
|
|
from test.support import smtpd
|
2020-04-25 05:35:18 -03:00
|
|
|
from test.support.logging_helper import TestHandler
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import textwrap
|
2017-09-07 13:56:24 -03:00
|
|
|
import threading
|
2022-05-26 05:30:51 -03:00
|
|
|
import asyncio
|
2011-04-26 16:26:41 -03:00
|
|
|
import time
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import unittest
|
2008-12-07 11:30:06 -04:00
|
|
|
import warnings
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
import weakref
|
2017-09-07 13:56:24 -03:00
|
|
|
|
|
|
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
|
|
|
from urllib.parse import urlparse, parse_qs
|
|
|
|
from socketserver import (ThreadingUDPServer, DatagramRequestHandler,
|
|
|
|
ThreadingTCPServer, StreamRequestHandler)
|
|
|
|
|
2011-05-09 13:32:09 -03:00
|
|
|
try:
|
2015-10-01 16:37:54 -03:00
|
|
|
import win32evtlog, win32evtlogutil, pywintypes
|
2011-05-09 13:32:09 -03:00
|
|
|
except ImportError:
|
2015-10-01 16:37:54 -03:00
|
|
|
win32evtlog = win32evtlogutil = pywintypes = None
|
|
|
|
|
2012-03-12 02:46:04 -03:00
|
|
|
try:
|
|
|
|
import zlib
|
|
|
|
except ImportError:
|
|
|
|
pass
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
|
2023-10-10 21:57:53 -03:00
|
|
|
# gh-89363: Skip fork() test if Python is built with Address Sanitizer (ASAN)
|
|
|
|
# to work around a libasan race condition, dead lock in pthread_create().
|
|
|
|
skip_if_asan_fork = unittest.skipIf(
|
|
|
|
support.HAVE_ASAN_FORK_BUG,
|
|
|
|
"libasan has a pthread_create() dead lock related to thread+fork")
|
|
|
|
|
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class BaseTest(unittest.TestCase):
|
|
|
|
|
|
|
|
"""Base class for logging tests."""
|
|
|
|
|
|
|
|
log_format = "%(name)s -> %(levelname)s: %(message)s"
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^([\w.]+) -> (\w+): (\d+)$"
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
message_num = 0
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""Setup the default logging stream to an internal StringIO instance,
|
|
|
|
so that we can examine log output as we want."""
|
2020-05-27 19:10:27 -03:00
|
|
|
self._threading_key = threading_helper.threading_setup()
|
2017-08-18 18:47:54 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logger_dict = logging.getLogger().manager.loggerDict
|
2023-09-27 13:26:41 -03:00
|
|
|
with logging._lock:
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.saved_handlers = logging._handlers.copy()
|
|
|
|
self.saved_handler_list = logging._handlerList[:]
|
2010-12-27 10:31:52 -04:00
|
|
|
self.saved_loggers = saved_loggers = logger_dict.copy()
|
2013-05-25 07:20:34 -03:00
|
|
|
self.saved_name_to_level = logging._nameToLevel.copy()
|
|
|
|
self.saved_level_to_name = logging._levelToName.copy()
|
2010-12-27 10:31:52 -04:00
|
|
|
self.logger_states = logger_states = {}
|
|
|
|
for name in saved_loggers:
|
|
|
|
logger_states[name] = getattr(saved_loggers[name],
|
|
|
|
'disabled', None)
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
2011-11-07 14:43:05 -04:00
|
|
|
# Set two unused loggers
|
2010-09-20 06:55:00 -03:00
|
|
|
self.logger1 = logging.getLogger("\xab\xd7\xbb")
|
|
|
|
self.logger2 = logging.getLogger("\u013f\u00d6\u0047")
|
Merged revisions 79279,79284,79293,79373,79376,79379,79876,79888 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79279 | vinay.sajip | 2010-03-22 07:33:08 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8200: logging: Handle errors when multiprocessing is not fully loaded when logging occurs.
........
r79284 | vinay.sajip | 2010-03-22 08:02:28 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8201: logging: Handle config errors when non-ASCII and Unicode logger names exist at the same time.
........
r79293 | vinay.sajip | 2010-03-22 10:29:01 -0500 (Mon, 22 Mar 2010) | 1 line
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
........
r79373 | vinay.sajip | 2010-03-24 09:31:21 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Added LOG_FTP for SysLogHandler and updated documentation.
........
r79376 | vinay.sajip | 2010-03-24 10:10:40 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Documentation tweak.
........
r79379 | vinay.sajip | 2010-03-24 12:36:35 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Updated SysLogHandler documentation.
........
r79876 | vinay.sajip | 2010-04-06 17:32:37 -0500 (Tue, 06 Apr 2010) | 1 line
Issue #8327: logging: Clarification of propagation functionality in documentation.
........
r79888 | vinay.sajip | 2010-04-07 04:40:52 -0500 (Wed, 07 Apr 2010) | 1 line
Issue #8331: logging: fixed some grammatical errors in documentation.
........
2010-04-11 13:25:06 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.root_logger = logging.getLogger("")
|
|
|
|
self.original_logging_level = self.root_logger.getEffectiveLevel()
|
|
|
|
|
|
|
|
self.stream = io.StringIO()
|
|
|
|
self.root_logger.setLevel(logging.DEBUG)
|
|
|
|
self.root_hdlr = logging.StreamHandler(self.stream)
|
|
|
|
self.root_formatter = logging.Formatter(self.log_format)
|
|
|
|
self.root_hdlr.setFormatter(self.root_formatter)
|
2010-12-30 19:26:50 -04:00
|
|
|
if self.logger1.hasHandlers():
|
|
|
|
hlist = self.logger1.handlers + self.root_logger.handlers
|
|
|
|
raise AssertionError('Unexpected handlers: %s' % hlist)
|
|
|
|
if self.logger2.hasHandlers():
|
|
|
|
hlist = self.logger2.handlers + self.root_logger.handlers
|
|
|
|
raise AssertionError('Unexpected handlers: %s' % hlist)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.root_logger.addHandler(self.root_hdlr)
|
2010-09-20 06:55:00 -03:00
|
|
|
self.assertTrue(self.logger1.hasHandlers())
|
|
|
|
self.assertTrue(self.logger2.hasHandlers())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""Remove our logging stream, and restore the original logging
|
|
|
|
level."""
|
|
|
|
self.stream.close()
|
|
|
|
self.root_logger.removeHandler(self.root_hdlr)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
while self.root_logger.handlers:
|
|
|
|
h = self.root_logger.handlers[0]
|
|
|
|
self.root_logger.removeHandler(h)
|
|
|
|
h.close()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.root_logger.setLevel(self.original_logging_level)
|
2023-09-27 13:26:41 -03:00
|
|
|
with logging._lock:
|
2013-05-25 07:20:34 -03:00
|
|
|
logging._levelToName.clear()
|
|
|
|
logging._levelToName.update(self.saved_level_to_name)
|
|
|
|
logging._nameToLevel.clear()
|
|
|
|
logging._nameToLevel.update(self.saved_name_to_level)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logging._handlers.clear()
|
|
|
|
logging._handlers.update(self.saved_handlers)
|
|
|
|
logging._handlerList[:] = self.saved_handler_list
|
2017-07-30 06:36:33 -03:00
|
|
|
manager = logging.getLogger().manager
|
|
|
|
manager.disable = 0
|
|
|
|
loggerDict = manager.loggerDict
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
loggerDict.clear()
|
|
|
|
loggerDict.update(self.saved_loggers)
|
2010-12-27 10:31:52 -04:00
|
|
|
logger_states = self.logger_states
|
|
|
|
for name in self.logger_states:
|
|
|
|
if logger_states[name] is not None:
|
|
|
|
self.saved_loggers[name].disabled = logger_states[name]
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
2017-08-18 18:47:54 -03:00
|
|
|
self.doCleanups()
|
2020-05-27 19:10:27 -03:00
|
|
|
threading_helper.threading_cleanup(*self._threading_key)
|
2017-08-18 18:47:54 -03:00
|
|
|
|
2012-10-02 11:56:16 -03:00
|
|
|
def assert_log_lines(self, expected_values, stream=None, pat=None):
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
"""Match the collected log lines against the regular expression
|
|
|
|
self.expected_log_pat, and compare the extracted group values to
|
|
|
|
the expected_values list of tuples."""
|
|
|
|
stream = stream or self.stream
|
2012-10-02 11:56:16 -03:00
|
|
|
pat = re.compile(pat or self.expected_log_pat)
|
2013-08-29 05:35:43 -03:00
|
|
|
actual_lines = stream.getvalue().splitlines()
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertEqual(len(actual_lines), len(expected_values))
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
for actual, expected in zip(actual_lines, expected_values):
|
|
|
|
match = pat.search(actual)
|
|
|
|
if not match:
|
|
|
|
self.fail("Log line does not match expected pattern:\n" +
|
|
|
|
actual)
|
2010-11-20 15:04:17 -04:00
|
|
|
self.assertEqual(tuple(match.groups()), expected)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
s = stream.read()
|
|
|
|
if s:
|
|
|
|
self.fail("Remaining output at end of log stream:\n" + s)
|
|
|
|
|
|
|
|
def next_message(self):
|
|
|
|
"""Generate a message consisting solely of an auto-incrementing
|
|
|
|
integer."""
|
|
|
|
self.message_num += 1
|
|
|
|
return "%d" % self.message_num
|
|
|
|
|
|
|
|
|
|
|
|
class BuiltinLevelsTest(BaseTest):
|
|
|
|
"""Test builtin levels and their inheritance."""
|
|
|
|
|
|
|
|
def test_flat(self):
|
2017-12-14 07:04:53 -04:00
|
|
|
# Logging levels in a flat logger namespace.
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
m = self.next_message
|
|
|
|
|
|
|
|
ERR = logging.getLogger("ERR")
|
|
|
|
ERR.setLevel(logging.ERROR)
|
2010-09-21 08:25:39 -03:00
|
|
|
INF = logging.LoggerAdapter(logging.getLogger("INF"), {})
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
INF.setLevel(logging.INFO)
|
|
|
|
DEB = logging.getLogger("DEB")
|
|
|
|
DEB.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
# These should log.
|
|
|
|
ERR.log(logging.CRITICAL, m())
|
|
|
|
ERR.error(m())
|
|
|
|
|
|
|
|
INF.log(logging.CRITICAL, m())
|
|
|
|
INF.error(m())
|
2011-10-26 09:17:20 -03:00
|
|
|
INF.warning(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
INF.info(m())
|
|
|
|
|
|
|
|
DEB.log(logging.CRITICAL, m())
|
|
|
|
DEB.error(m())
|
2011-10-26 09:17:20 -03:00
|
|
|
DEB.warning(m())
|
|
|
|
DEB.info(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
DEB.debug(m())
|
|
|
|
|
|
|
|
# These should not log.
|
2011-10-26 09:17:20 -03:00
|
|
|
ERR.warning(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
ERR.info(m())
|
|
|
|
ERR.debug(m())
|
|
|
|
|
|
|
|
INF.debug(m())
|
|
|
|
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('ERR', 'CRITICAL', '1'),
|
|
|
|
('ERR', 'ERROR', '2'),
|
|
|
|
('INF', 'CRITICAL', '3'),
|
|
|
|
('INF', 'ERROR', '4'),
|
|
|
|
('INF', 'WARNING', '5'),
|
|
|
|
('INF', 'INFO', '6'),
|
|
|
|
('DEB', 'CRITICAL', '7'),
|
|
|
|
('DEB', 'ERROR', '8'),
|
|
|
|
('DEB', 'WARNING', '9'),
|
|
|
|
('DEB', 'INFO', '10'),
|
|
|
|
('DEB', 'DEBUG', '11'),
|
|
|
|
])
|
|
|
|
|
|
|
|
def test_nested_explicit(self):
|
|
|
|
# Logging levels in a nested namespace, all explicitly set.
|
|
|
|
m = self.next_message
|
|
|
|
|
|
|
|
INF = logging.getLogger("INF")
|
|
|
|
INF.setLevel(logging.INFO)
|
|
|
|
INF_ERR = logging.getLogger("INF.ERR")
|
|
|
|
INF_ERR.setLevel(logging.ERROR)
|
|
|
|
|
|
|
|
# These should log.
|
|
|
|
INF_ERR.log(logging.CRITICAL, m())
|
|
|
|
INF_ERR.error(m())
|
|
|
|
|
|
|
|
# These should not log.
|
2011-10-26 09:17:20 -03:00
|
|
|
INF_ERR.warning(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
INF_ERR.info(m())
|
|
|
|
INF_ERR.debug(m())
|
|
|
|
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('INF.ERR', 'CRITICAL', '1'),
|
|
|
|
('INF.ERR', 'ERROR', '2'),
|
|
|
|
])
|
|
|
|
|
|
|
|
def test_nested_inherited(self):
|
2017-12-14 07:04:53 -04:00
|
|
|
# Logging levels in a nested namespace, inherited from parent loggers.
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
m = self.next_message
|
|
|
|
|
|
|
|
INF = logging.getLogger("INF")
|
|
|
|
INF.setLevel(logging.INFO)
|
|
|
|
INF_ERR = logging.getLogger("INF.ERR")
|
|
|
|
INF_ERR.setLevel(logging.ERROR)
|
|
|
|
INF_UNDEF = logging.getLogger("INF.UNDEF")
|
|
|
|
INF_ERR_UNDEF = logging.getLogger("INF.ERR.UNDEF")
|
|
|
|
UNDEF = logging.getLogger("UNDEF")
|
|
|
|
|
|
|
|
# These should log.
|
|
|
|
INF_UNDEF.log(logging.CRITICAL, m())
|
|
|
|
INF_UNDEF.error(m())
|
2011-10-26 09:17:20 -03:00
|
|
|
INF_UNDEF.warning(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
INF_UNDEF.info(m())
|
|
|
|
INF_ERR_UNDEF.log(logging.CRITICAL, m())
|
|
|
|
INF_ERR_UNDEF.error(m())
|
|
|
|
|
|
|
|
# These should not log.
|
|
|
|
INF_UNDEF.debug(m())
|
2011-10-26 09:17:20 -03:00
|
|
|
INF_ERR_UNDEF.warning(m())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
INF_ERR_UNDEF.info(m())
|
|
|
|
INF_ERR_UNDEF.debug(m())
|
|
|
|
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('INF.UNDEF', 'CRITICAL', '1'),
|
|
|
|
('INF.UNDEF', 'ERROR', '2'),
|
|
|
|
('INF.UNDEF', 'WARNING', '3'),
|
|
|
|
('INF.UNDEF', 'INFO', '4'),
|
|
|
|
('INF.ERR.UNDEF', 'CRITICAL', '5'),
|
|
|
|
('INF.ERR.UNDEF', 'ERROR', '6'),
|
|
|
|
])
|
|
|
|
|
|
|
|
def test_nested_with_virtual_parent(self):
|
|
|
|
# Logging levels when some parent does not exist yet.
|
|
|
|
m = self.next_message
|
|
|
|
|
|
|
|
INF = logging.getLogger("INF")
|
|
|
|
GRANDCHILD = logging.getLogger("INF.BADPARENT.UNDEF")
|
|
|
|
CHILD = logging.getLogger("INF.BADPARENT")
|
|
|
|
INF.setLevel(logging.INFO)
|
|
|
|
|
|
|
|
# These should log.
|
|
|
|
GRANDCHILD.log(logging.FATAL, m())
|
|
|
|
GRANDCHILD.info(m())
|
|
|
|
CHILD.log(logging.FATAL, m())
|
|
|
|
CHILD.info(m())
|
|
|
|
|
|
|
|
# These should not log.
|
|
|
|
GRANDCHILD.debug(m())
|
|
|
|
CHILD.debug(m())
|
|
|
|
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('INF.BADPARENT.UNDEF', 'CRITICAL', '1'),
|
|
|
|
('INF.BADPARENT.UNDEF', 'INFO', '2'),
|
|
|
|
('INF.BADPARENT', 'CRITICAL', '3'),
|
|
|
|
('INF.BADPARENT', 'INFO', '4'),
|
|
|
|
])
|
|
|
|
|
2014-09-11 19:06:09 -03:00
|
|
|
def test_regression_22386(self):
|
|
|
|
"""See issue #22386 for more information."""
|
|
|
|
self.assertEqual(logging.getLevelName('INFO'), logging.INFO)
|
|
|
|
self.assertEqual(logging.getLevelName(logging.INFO), 'INFO')
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2016-09-07 21:37:03 -03:00
|
|
|
def test_issue27935(self):
|
|
|
|
fatal = logging.getLevelName('FATAL')
|
|
|
|
self.assertEqual(fatal, logging.FATAL)
|
|
|
|
|
2017-01-11 13:35:36 -04:00
|
|
|
def test_regression_29220(self):
|
|
|
|
"""See issue #29220 for more information."""
|
|
|
|
logging.addLevelName(logging.INFO, '')
|
|
|
|
self.addCleanup(logging.addLevelName, logging.INFO, 'INFO')
|
|
|
|
self.assertEqual(logging.getLevelName(logging.INFO), '')
|
|
|
|
self.assertEqual(logging.getLevelName(logging.NOTSET), 'NOTSET')
|
|
|
|
self.assertEqual(logging.getLevelName('NOTSET'), logging.NOTSET)
|
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class BasicFilterTest(BaseTest):
|
|
|
|
|
|
|
|
"""Test the bundled Filter class."""
|
|
|
|
|
|
|
|
def test_filter(self):
|
|
|
|
# Only messages satisfying the specified criteria pass through the
|
|
|
|
# filter.
|
|
|
|
filter_ = logging.Filter("spam.eggs")
|
|
|
|
handler = self.root_logger.handlers[0]
|
|
|
|
try:
|
|
|
|
handler.addFilter(filter_)
|
|
|
|
spam = logging.getLogger("spam")
|
|
|
|
spam_eggs = logging.getLogger("spam.eggs")
|
|
|
|
spam_eggs_fish = logging.getLogger("spam.eggs.fish")
|
|
|
|
spam_bakedbeans = logging.getLogger("spam.bakedbeans")
|
|
|
|
|
|
|
|
spam.info(self.next_message())
|
|
|
|
spam_eggs.info(self.next_message()) # Good.
|
|
|
|
spam_eggs_fish.info(self.next_message()) # Good.
|
|
|
|
spam_bakedbeans.info(self.next_message())
|
|
|
|
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('spam.eggs', 'INFO', '2'),
|
|
|
|
('spam.eggs.fish', 'INFO', '3'),
|
|
|
|
])
|
|
|
|
finally:
|
|
|
|
handler.removeFilter(filter_)
|
|
|
|
|
2010-10-19 17:53:01 -03:00
|
|
|
def test_callable_filter(self):
|
|
|
|
# Only messages satisfying the specified criteria pass through the
|
|
|
|
# filter.
|
|
|
|
|
|
|
|
def filterfunc(record):
|
|
|
|
parts = record.name.split('.')
|
|
|
|
prefix = '.'.join(parts[:2])
|
|
|
|
return prefix == 'spam.eggs'
|
|
|
|
|
|
|
|
handler = self.root_logger.handlers[0]
|
|
|
|
try:
|
|
|
|
handler.addFilter(filterfunc)
|
|
|
|
spam = logging.getLogger("spam")
|
|
|
|
spam_eggs = logging.getLogger("spam.eggs")
|
|
|
|
spam_eggs_fish = logging.getLogger("spam.eggs.fish")
|
|
|
|
spam_bakedbeans = logging.getLogger("spam.bakedbeans")
|
|
|
|
|
|
|
|
spam.info(self.next_message())
|
|
|
|
spam_eggs.info(self.next_message()) # Good.
|
|
|
|
spam_eggs_fish.info(self.next_message()) # Good.
|
|
|
|
spam_bakedbeans.info(self.next_message())
|
|
|
|
|
|
|
|
self.assert_log_lines([
|
|
|
|
('spam.eggs', 'INFO', '2'),
|
|
|
|
('spam.eggs.fish', 'INFO', '3'),
|
|
|
|
])
|
|
|
|
finally:
|
|
|
|
handler.removeFilter(filterfunc)
|
|
|
|
|
2011-04-26 15:34:04 -03:00
|
|
|
def test_empty_filter(self):
|
|
|
|
f = logging.Filter()
|
|
|
|
r = logging.makeLogRecord({'name': 'spam.eggs'})
|
|
|
|
self.assertTrue(f.filter(r))
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# First, we define our levels. There can be as many as you want - the only
|
|
|
|
# limitations are that they should be integers, the lowest should be > 0 and
|
|
|
|
# larger values mean less information being logged. If you need specific
|
|
|
|
# level values which do not fit into these limitations, you can use a
|
|
|
|
# mapping dictionary to convert between your application levels and the
|
|
|
|
# logging system.
|
|
|
|
#
|
|
|
|
SILENT = 120
|
|
|
|
TACITURN = 119
|
|
|
|
TERSE = 118
|
|
|
|
EFFUSIVE = 117
|
|
|
|
SOCIABLE = 116
|
|
|
|
VERBOSE = 115
|
|
|
|
TALKATIVE = 114
|
|
|
|
GARRULOUS = 113
|
|
|
|
CHATTERBOX = 112
|
|
|
|
BORING = 111
|
|
|
|
|
|
|
|
LEVEL_RANGE = range(BORING, SILENT + 1)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Next, we define names for our levels. You don't need to do this - in which
|
|
|
|
# case the system will use "Level n" to denote the text for the level.
|
|
|
|
#
|
|
|
|
my_logging_levels = {
|
|
|
|
SILENT : 'Silent',
|
|
|
|
TACITURN : 'Taciturn',
|
|
|
|
TERSE : 'Terse',
|
|
|
|
EFFUSIVE : 'Effusive',
|
|
|
|
SOCIABLE : 'Sociable',
|
|
|
|
VERBOSE : 'Verbose',
|
|
|
|
TALKATIVE : 'Talkative',
|
|
|
|
GARRULOUS : 'Garrulous',
|
|
|
|
CHATTERBOX : 'Chatterbox',
|
|
|
|
BORING : 'Boring',
|
|
|
|
}
|
|
|
|
|
|
|
|
class GarrulousFilter(logging.Filter):
|
|
|
|
|
|
|
|
"""A filter which blocks garrulous messages."""
|
|
|
|
|
|
|
|
def filter(self, record):
|
|
|
|
return record.levelno != GARRULOUS
|
|
|
|
|
|
|
|
class VerySpecificFilter(logging.Filter):
|
|
|
|
|
|
|
|
"""A filter which blocks sociable and taciturn messages."""
|
|
|
|
|
|
|
|
def filter(self, record):
|
|
|
|
return record.levelno not in [SOCIABLE, TACITURN]
|
|
|
|
|
|
|
|
|
|
|
|
class CustomLevelsAndFiltersTest(BaseTest):
|
|
|
|
|
|
|
|
"""Test various filtering possibilities with custom logging levels."""
|
|
|
|
|
|
|
|
# Skip the logger name group.
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^[\w.]+ -> (\w+): (\d+)$"
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
BaseTest.setUp(self)
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
for k, v in my_logging_levels.items():
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logging.addLevelName(k, v)
|
|
|
|
|
|
|
|
def log_at_all_levels(self, logger):
|
|
|
|
for lvl in LEVEL_RANGE:
|
|
|
|
logger.log(lvl, self.next_message())
|
|
|
|
|
2022-06-07 12:53:57 -03:00
|
|
|
def test_handler_filter_replaces_record(self):
|
|
|
|
def replace_message(record: logging.LogRecord):
|
|
|
|
record = copy.copy(record)
|
|
|
|
record.msg = "new message!"
|
|
|
|
return record
|
|
|
|
|
|
|
|
# Set up a logging hierarchy such that "child" and it's handler
|
|
|
|
# (and thus `replace_message()`) always get called before
|
|
|
|
# propagating up to "parent".
|
|
|
|
# Then we can confirm that `replace_message()` was able to
|
|
|
|
# replace the log record without having a side effect on
|
|
|
|
# other loggers or handlers.
|
|
|
|
parent = logging.getLogger("parent")
|
|
|
|
child = logging.getLogger("parent.child")
|
|
|
|
stream_1 = io.StringIO()
|
|
|
|
stream_2 = io.StringIO()
|
|
|
|
handler_1 = logging.StreamHandler(stream_1)
|
|
|
|
handler_2 = logging.StreamHandler(stream_2)
|
|
|
|
handler_2.addFilter(replace_message)
|
|
|
|
parent.addHandler(handler_1)
|
|
|
|
child.addHandler(handler_2)
|
|
|
|
|
|
|
|
child.info("original message")
|
|
|
|
handler_1.flush()
|
|
|
|
handler_2.flush()
|
|
|
|
self.assertEqual(stream_1.getvalue(), "original message\n")
|
|
|
|
self.assertEqual(stream_2.getvalue(), "new message!\n")
|
|
|
|
|
|
|
|
def test_logging_filter_replaces_record(self):
|
|
|
|
records = set()
|
|
|
|
|
|
|
|
class RecordingFilter(logging.Filter):
|
|
|
|
def filter(self, record: logging.LogRecord):
|
|
|
|
records.add(id(record))
|
|
|
|
return copy.copy(record)
|
|
|
|
|
|
|
|
logger = logging.getLogger("logger")
|
|
|
|
logger.setLevel(logging.INFO)
|
|
|
|
logger.addFilter(RecordingFilter())
|
|
|
|
logger.addFilter(RecordingFilter())
|
|
|
|
|
|
|
|
logger.info("msg")
|
|
|
|
|
|
|
|
self.assertEqual(2, len(records))
|
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
def test_logger_filter(self):
|
|
|
|
# Filter at logger level.
|
|
|
|
self.root_logger.setLevel(VERBOSE)
|
|
|
|
# Levels >= 'Verbose' are good.
|
|
|
|
self.log_at_all_levels(self.root_logger)
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('Verbose', '5'),
|
|
|
|
('Sociable', '6'),
|
|
|
|
('Effusive', '7'),
|
|
|
|
('Terse', '8'),
|
|
|
|
('Taciturn', '9'),
|
|
|
|
('Silent', '10'),
|
|
|
|
])
|
|
|
|
|
|
|
|
def test_handler_filter(self):
|
|
|
|
# Filter at handler level.
|
|
|
|
self.root_logger.handlers[0].setLevel(SOCIABLE)
|
|
|
|
try:
|
|
|
|
# Levels >= 'Sociable' are good.
|
|
|
|
self.log_at_all_levels(self.root_logger)
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('Sociable', '6'),
|
|
|
|
('Effusive', '7'),
|
|
|
|
('Terse', '8'),
|
|
|
|
('Taciturn', '9'),
|
|
|
|
('Silent', '10'),
|
|
|
|
])
|
|
|
|
finally:
|
|
|
|
self.root_logger.handlers[0].setLevel(logging.NOTSET)
|
|
|
|
|
|
|
|
def test_specific_filters(self):
|
|
|
|
# Set a specific filter object on the handler, and then add another
|
|
|
|
# filter object on the logger itself.
|
|
|
|
handler = self.root_logger.handlers[0]
|
|
|
|
specific_filter = None
|
|
|
|
garr = GarrulousFilter()
|
|
|
|
handler.addFilter(garr)
|
|
|
|
try:
|
|
|
|
self.log_at_all_levels(self.root_logger)
|
|
|
|
first_lines = [
|
|
|
|
# Notice how 'Garrulous' is missing
|
|
|
|
('Boring', '1'),
|
|
|
|
('Chatterbox', '2'),
|
|
|
|
('Talkative', '4'),
|
|
|
|
('Verbose', '5'),
|
|
|
|
('Sociable', '6'),
|
|
|
|
('Effusive', '7'),
|
|
|
|
('Terse', '8'),
|
|
|
|
('Taciturn', '9'),
|
|
|
|
('Silent', '10'),
|
|
|
|
]
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(first_lines)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
specific_filter = VerySpecificFilter()
|
|
|
|
self.root_logger.addFilter(specific_filter)
|
|
|
|
self.log_at_all_levels(self.root_logger)
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(first_lines + [
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# Not only 'Garrulous' is still missing, but also 'Sociable'
|
|
|
|
# and 'Taciturn'
|
|
|
|
('Boring', '11'),
|
|
|
|
('Chatterbox', '12'),
|
|
|
|
('Talkative', '14'),
|
|
|
|
('Verbose', '15'),
|
|
|
|
('Effusive', '17'),
|
|
|
|
('Terse', '18'),
|
|
|
|
('Silent', '20'),
|
|
|
|
])
|
|
|
|
finally:
|
|
|
|
if specific_filter:
|
|
|
|
self.root_logger.removeFilter(specific_filter)
|
|
|
|
handler.removeFilter(garr)
|
|
|
|
|
|
|
|
|
2022-05-26 13:11:15 -03:00
|
|
|
def make_temp_file(*args, **kwargs):
|
|
|
|
fd, fn = tempfile.mkstemp(*args, **kwargs)
|
|
|
|
os.close(fd)
|
|
|
|
return fn
|
|
|
|
|
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
class HandlerTest(BaseTest):
|
|
|
|
def test_name(self):
|
|
|
|
h = logging.Handler()
|
|
|
|
h.name = 'generic'
|
|
|
|
self.assertEqual(h.name, 'generic')
|
|
|
|
h.name = 'anothergeneric'
|
|
|
|
self.assertEqual(h.name, 'anothergeneric')
|
|
|
|
self.assertRaises(NotImplementedError, h.emit, None)
|
|
|
|
|
2011-04-27 07:31:14 -03:00
|
|
|
def test_builtin_handlers(self):
|
|
|
|
# We can't actually *use* too many handlers in the tests,
|
|
|
|
# but we can try instantiating them with various options
|
2011-08-20 19:39:18 -03:00
|
|
|
if sys.platform in ('linux', 'darwin'):
|
2011-04-27 07:31:14 -03:00
|
|
|
for existing in (True, False):
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file()
|
2011-04-27 07:31:14 -03:00
|
|
|
if not existing:
|
|
|
|
os.unlink(fn)
|
2021-04-05 23:18:41 -03:00
|
|
|
h = logging.handlers.WatchedFileHandler(fn, encoding='utf-8', delay=True)
|
2011-04-27 07:31:14 -03:00
|
|
|
if existing:
|
2011-04-28 08:04:58 -03:00
|
|
|
dev, ino = h.dev, h.ino
|
2012-04-24 19:33:33 -03:00
|
|
|
self.assertEqual(dev, -1)
|
|
|
|
self.assertEqual(ino, -1)
|
2011-04-28 08:04:58 -03:00
|
|
|
r = logging.makeLogRecord({'msg': 'Test'})
|
|
|
|
h.handle(r)
|
|
|
|
# Now remove the file.
|
|
|
|
os.unlink(fn)
|
|
|
|
self.assertFalse(os.path.exists(fn))
|
|
|
|
# The next call should recreate the file.
|
|
|
|
h.handle(r)
|
|
|
|
self.assertTrue(os.path.exists(fn))
|
2011-04-27 07:31:14 -03:00
|
|
|
else:
|
|
|
|
self.assertEqual(h.dev, -1)
|
|
|
|
self.assertEqual(h.ino, -1)
|
|
|
|
h.close()
|
|
|
|
if existing:
|
|
|
|
os.unlink(fn)
|
|
|
|
if sys.platform == 'darwin':
|
2011-04-27 10:31:55 -03:00
|
|
|
sockname = '/var/run/syslog'
|
2011-04-27 07:31:14 -03:00
|
|
|
else:
|
|
|
|
sockname = '/dev/log'
|
2011-04-27 10:18:06 -03:00
|
|
|
try:
|
|
|
|
h = logging.handlers.SysLogHandler(sockname)
|
|
|
|
self.assertEqual(h.facility, h.LOG_USER)
|
|
|
|
self.assertTrue(h.unixsocket)
|
|
|
|
h.close()
|
2012-12-18 17:10:48 -04:00
|
|
|
except OSError: # syslogd might not be available
|
2011-04-27 10:18:06 -03:00
|
|
|
pass
|
2011-04-27 07:31:14 -03:00
|
|
|
for method in ('GET', 'POST', 'PUT'):
|
|
|
|
if method == 'PUT':
|
|
|
|
self.assertRaises(ValueError, logging.handlers.HTTPHandler,
|
|
|
|
'localhost', '/log', method)
|
|
|
|
else:
|
|
|
|
h = logging.handlers.HTTPHandler('localhost', '/log', method)
|
|
|
|
h.close()
|
|
|
|
h = logging.handlers.BufferingHandler(0)
|
|
|
|
r = logging.makeLogRecord({})
|
|
|
|
self.assertTrue(h.shouldFlush(r))
|
|
|
|
h.close()
|
|
|
|
h = logging.handlers.BufferingHandler(1)
|
|
|
|
self.assertFalse(h.shouldFlush(r))
|
|
|
|
h.close()
|
2011-04-26 14:43:05 -03:00
|
|
|
|
2016-09-07 21:37:03 -03:00
|
|
|
def test_path_objects(self):
|
|
|
|
"""
|
|
|
|
Test that Path objects are accepted as filename arguments to handlers.
|
|
|
|
|
|
|
|
See Issue #27493.
|
|
|
|
"""
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file()
|
2016-09-07 21:37:03 -03:00
|
|
|
os.unlink(fn)
|
|
|
|
pfn = pathlib.Path(fn)
|
|
|
|
cases = (
|
|
|
|
(logging.FileHandler, (pfn, 'w')),
|
|
|
|
(logging.handlers.RotatingFileHandler, (pfn, 'a')),
|
|
|
|
(logging.handlers.TimedRotatingFileHandler, (pfn, 'h')),
|
|
|
|
)
|
|
|
|
if sys.platform in ('linux', 'darwin'):
|
|
|
|
cases += ((logging.handlers.WatchedFileHandler, (pfn, 'w')),)
|
|
|
|
for cls, args in cases:
|
2021-04-05 23:18:41 -03:00
|
|
|
h = cls(*args, encoding="utf-8")
|
2016-09-07 21:37:03 -03:00
|
|
|
self.assertTrue(os.path.exists(fn))
|
|
|
|
h.close()
|
|
|
|
os.unlink(fn)
|
|
|
|
|
2012-05-29 18:48:10 -03:00
|
|
|
@unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
|
2022-03-22 07:04:36 -03:00
|
|
|
@unittest.skipIf(
|
|
|
|
support.is_emscripten, "Emscripten cannot fstat unlinked files."
|
|
|
|
)
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2023-09-05 11:56:30 -03:00
|
|
|
@support.requires_resource('walltime')
|
2012-04-24 19:33:33 -03:00
|
|
|
def test_race(self):
|
|
|
|
# Issue #14632 refers.
|
|
|
|
def remove_loop(fname, tries):
|
|
|
|
for _ in range(tries):
|
|
|
|
try:
|
|
|
|
os.unlink(fname)
|
2013-12-03 08:31:23 -04:00
|
|
|
self.deletion_time = time.time()
|
2012-04-24 19:33:33 -03:00
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
time.sleep(0.004 * random.randint(0, 4))
|
|
|
|
|
2012-04-25 06:51:35 -03:00
|
|
|
del_count = 500
|
|
|
|
log_count = 500
|
|
|
|
|
2013-12-03 08:31:23 -04:00
|
|
|
self.handle_time = None
|
|
|
|
self.deletion_time = None
|
|
|
|
|
2012-04-24 19:33:33 -03:00
|
|
|
for delay in (False, True):
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file('.log', 'test_logging-3-')
|
2012-04-25 06:51:35 -03:00
|
|
|
remover = threading.Thread(target=remove_loop, args=(fn, del_count))
|
|
|
|
remover.daemon = True
|
|
|
|
remover.start()
|
2021-04-05 23:18:41 -03:00
|
|
|
h = logging.handlers.WatchedFileHandler(fn, encoding='utf-8', delay=delay)
|
2012-04-24 19:33:33 -03:00
|
|
|
f = logging.Formatter('%(asctime)s: %(levelname)s: %(message)s')
|
|
|
|
h.setFormatter(f)
|
2012-04-25 06:51:35 -03:00
|
|
|
try:
|
|
|
|
for _ in range(log_count):
|
|
|
|
time.sleep(0.005)
|
|
|
|
r = logging.makeLogRecord({'msg': 'testing' })
|
2013-12-03 08:31:23 -04:00
|
|
|
try:
|
|
|
|
self.handle_time = time.time()
|
|
|
|
h.handle(r)
|
|
|
|
except Exception:
|
|
|
|
print('Deleted at %s, '
|
|
|
|
'opened at %s' % (self.deletion_time,
|
|
|
|
self.handle_time))
|
|
|
|
raise
|
2012-04-25 06:51:35 -03:00
|
|
|
finally:
|
|
|
|
remover.join()
|
2012-05-03 08:09:38 -03:00
|
|
|
h.close()
|
2012-04-25 06:51:35 -03:00
|
|
|
if os.path.exists(fn):
|
|
|
|
os.unlink(fn)
|
2012-04-24 19:33:33 -03:00
|
|
|
|
2018-09-14 02:08:31 -03:00
|
|
|
# The implementation relies on os.register_at_fork existing, but we test
|
|
|
|
# based on os.fork existing because that is what users and this test use.
|
|
|
|
# This helps ensure that when fork exists (the important concept) that the
|
|
|
|
# register_at_fork mechanism is also present and used.
|
2022-03-17 08:09:57 -03:00
|
|
|
@support.requires_fork()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2023-10-10 21:57:53 -03:00
|
|
|
@skip_if_asan_fork
|
2018-09-14 02:08:31 -03:00
|
|
|
def test_post_fork_child_no_deadlock(self):
|
2019-05-07 13:18:20 -03:00
|
|
|
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
|
|
|
|
class _OurHandler(logging.Handler):
|
|
|
|
def __init__(self):
|
|
|
|
super().__init__()
|
|
|
|
self.sub_handler = logging.StreamHandler(
|
2021-04-05 23:18:41 -03:00
|
|
|
stream=open('/dev/null', 'wt', encoding='utf-8'))
|
2019-05-07 13:18:20 -03:00
|
|
|
|
|
|
|
def emit(self, record):
|
2023-09-27 13:26:41 -03:00
|
|
|
with self.sub_handler.lock:
|
2019-05-07 13:18:20 -03:00
|
|
|
self.sub_handler.emit(record)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging._handlers), 0)
|
|
|
|
refed_h = _OurHandler()
|
2019-05-13 11:48:52 -03:00
|
|
|
self.addCleanup(refed_h.sub_handler.stream.close)
|
2018-09-14 02:08:31 -03:00
|
|
|
refed_h.name = 'because we need at least one for this test'
|
|
|
|
self.assertGreater(len(logging._handlers), 0)
|
2019-05-07 13:18:20 -03:00
|
|
|
self.assertGreater(len(logging._at_fork_reinit_lock_weakset), 1)
|
|
|
|
test_logger = logging.getLogger('test_post_fork_child_no_deadlock')
|
|
|
|
test_logger.addHandler(refed_h)
|
|
|
|
test_logger.setLevel(logging.DEBUG)
|
2018-09-14 02:08:31 -03:00
|
|
|
|
|
|
|
locks_held__ready_to_fork = threading.Event()
|
|
|
|
fork_happened__release_locks_and_end_thread = threading.Event()
|
|
|
|
|
|
|
|
def lock_holder_thread_fn():
|
2023-09-27 13:26:41 -03:00
|
|
|
with logging._lock, refed_h.lock:
|
|
|
|
# Tell the main thread to do the fork.
|
|
|
|
locks_held__ready_to_fork.set()
|
|
|
|
|
|
|
|
# If the deadlock bug exists, the fork will happen
|
|
|
|
# without dealing with the locks we hold, deadlocking
|
|
|
|
# the child.
|
|
|
|
|
|
|
|
# Wait for a successful fork or an unreasonable amount of
|
|
|
|
# time before releasing our locks. To avoid a timing based
|
|
|
|
# test we'd need communication from os.fork() as to when it
|
|
|
|
# has actually happened. Given this is a regression test
|
|
|
|
# for a fixed issue, potentially less reliably detecting
|
|
|
|
# regression via timing is acceptable for simplicity.
|
|
|
|
# The test will always take at least this long. :(
|
|
|
|
fork_happened__release_locks_and_end_thread.wait(0.5)
|
2018-09-14 02:08:31 -03:00
|
|
|
|
|
|
|
lock_holder_thread = threading.Thread(
|
|
|
|
target=lock_holder_thread_fn,
|
|
|
|
name='test_post_fork_child_no_deadlock lock holder')
|
|
|
|
lock_holder_thread.start()
|
|
|
|
|
|
|
|
locks_held__ready_to_fork.wait()
|
|
|
|
pid = os.fork()
|
2020-03-31 15:08:12 -03:00
|
|
|
if pid == 0:
|
|
|
|
# Child process
|
2019-05-07 13:18:20 -03:00
|
|
|
try:
|
|
|
|
test_logger.info(r'Child process did not deadlock. \o/')
|
|
|
|
finally:
|
|
|
|
os._exit(0)
|
2020-03-31 15:08:12 -03:00
|
|
|
else:
|
|
|
|
# Parent process
|
2019-05-07 13:18:20 -03:00
|
|
|
test_logger.info(r'Parent process returned from fork. \o/')
|
2018-09-14 02:08:31 -03:00
|
|
|
fork_happened__release_locks_and_end_thread.set()
|
|
|
|
lock_holder_thread.join()
|
2020-03-31 15:08:12 -03:00
|
|
|
|
|
|
|
support.wait_process(pid, exitcode=0)
|
2018-09-14 02:08:31 -03:00
|
|
|
|
2012-04-24 19:33:33 -03:00
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
class BadStream(object):
|
|
|
|
def write(self, data):
|
|
|
|
raise RuntimeError('deliberate mistake')
|
|
|
|
|
|
|
|
class TestStreamHandler(logging.StreamHandler):
|
|
|
|
def handleError(self, record):
|
|
|
|
self.error_record = record
|
|
|
|
|
2019-05-07 18:36:39 -03:00
|
|
|
class StreamWithIntName(object):
|
|
|
|
level = logging.NOTSET
|
|
|
|
name = 2
|
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
class StreamHandlerTest(BaseTest):
|
|
|
|
def test_error_handling(self):
|
|
|
|
h = TestStreamHandler(BadStream())
|
|
|
|
r = logging.makeLogRecord({})
|
|
|
|
old_raise = logging.raiseExceptions
|
2014-05-31 04:19:12 -03:00
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
try:
|
|
|
|
h.handle(r)
|
|
|
|
self.assertIs(h.error_record, r)
|
2014-05-31 04:19:12 -03:00
|
|
|
|
2011-04-26 15:34:04 -03:00
|
|
|
h = logging.StreamHandler(BadStream())
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
h.handle(r)
|
|
|
|
msg = '\nRuntimeError: deliberate mistake\n'
|
|
|
|
self.assertIn(msg, stderr.getvalue())
|
|
|
|
|
2011-04-26 15:34:04 -03:00
|
|
|
logging.raiseExceptions = False
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
h.handle(r)
|
|
|
|
self.assertEqual('', stderr.getvalue())
|
2011-04-26 14:43:05 -03:00
|
|
|
finally:
|
|
|
|
logging.raiseExceptions = old_raise
|
|
|
|
|
2017-07-30 06:41:45 -03:00
|
|
|
def test_stream_setting(self):
|
|
|
|
"""
|
|
|
|
Test setting the handler's stream
|
|
|
|
"""
|
|
|
|
h = logging.StreamHandler()
|
|
|
|
stream = io.StringIO()
|
|
|
|
old = h.setStream(stream)
|
|
|
|
self.assertIs(old, sys.stderr)
|
|
|
|
actual = h.setStream(old)
|
|
|
|
self.assertIs(actual, stream)
|
|
|
|
# test that setting to existing value returns None
|
|
|
|
actual = h.setStream(old)
|
|
|
|
self.assertIsNone(actual)
|
|
|
|
|
2019-05-07 18:36:39 -03:00
|
|
|
def test_can_represent_stream_with_int_name(self):
|
|
|
|
h = logging.StreamHandler(StreamWithIntName())
|
|
|
|
self.assertEqual(repr(h), '<StreamHandler 2 (NOTSET)>')
|
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
# -- The following section could be moved into a server_helper.py module
|
|
|
|
# -- if it proves to be of wider utility than just test_logging
|
2011-04-30 17:52:48 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
class TestSMTPServer(smtpd.SMTPServer):
|
|
|
|
"""
|
|
|
|
This class implements a test SMTP server.
|
|
|
|
|
|
|
|
:param addr: A (host, port) tuple which the server listens on.
|
|
|
|
You can specify a port value of zero: the server's
|
|
|
|
*port* attribute will hold the actual port number
|
|
|
|
used, which can be used in client connections.
|
|
|
|
:param handler: A callable which will be called to process
|
|
|
|
incoming messages. The handler will be passed
|
|
|
|
the client address tuple, who the message is from,
|
|
|
|
a list of recipients and the message data.
|
|
|
|
:param poll_interval: The interval, in seconds, used in the underlying
|
|
|
|
:func:`select` or :func:`poll` call by
|
|
|
|
:func:`asyncore.loop`.
|
|
|
|
:param sockmap: A dictionary which will be used to hold
|
|
|
|
:class:`asyncore.dispatcher` instances used by
|
|
|
|
:func:`asyncore.loop`. This avoids changing the
|
|
|
|
:mod:`asyncore` module's global state.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self, addr, handler, poll_interval, sockmap):
|
|
|
|
smtpd.SMTPServer.__init__(self, addr, None, map=sockmap,
|
|
|
|
decode_data=True)
|
|
|
|
self.port = self.socket.getsockname()[1]
|
|
|
|
self._handler = handler
|
|
|
|
self._thread = None
|
2021-04-16 09:32:01 -03:00
|
|
|
self._quit = False
|
2017-09-07 13:56:24 -03:00
|
|
|
self.poll_interval = poll_interval
|
|
|
|
|
|
|
|
def process_message(self, peer, mailfrom, rcpttos, data):
|
|
|
|
"""
|
|
|
|
Delegates to the handler passed in to the server's constructor.
|
|
|
|
|
|
|
|
Typically, this will be a test case method.
|
|
|
|
:param peer: The client (host, port) tuple.
|
|
|
|
:param mailfrom: The address of the sender.
|
|
|
|
:param rcpttos: The addresses of the recipients.
|
|
|
|
:param data: The message.
|
2011-05-02 10:31:16 -03:00
|
|
|
"""
|
2017-09-07 13:56:24 -03:00
|
|
|
self._handler(peer, mailfrom, rcpttos, data)
|
|
|
|
|
|
|
|
def start(self):
|
|
|
|
"""
|
|
|
|
Start the server running on a separate daemon thread.
|
|
|
|
"""
|
|
|
|
self._thread = t = threading.Thread(target=self.serve_forever,
|
|
|
|
args=(self.poll_interval,))
|
2021-04-12 08:12:36 -03:00
|
|
|
t.daemon = True
|
2017-09-07 13:56:24 -03:00
|
|
|
t.start()
|
|
|
|
|
|
|
|
def serve_forever(self, poll_interval):
|
|
|
|
"""
|
|
|
|
Run the :mod:`asyncore` loop until normal termination
|
|
|
|
conditions arise.
|
2011-05-02 10:31:16 -03:00
|
|
|
:param poll_interval: The interval, in seconds, used in the underlying
|
|
|
|
:func:`select` or :func:`poll` call by
|
|
|
|
:func:`asyncore.loop`.
|
|
|
|
"""
|
2021-04-16 09:32:01 -03:00
|
|
|
while not self._quit:
|
|
|
|
asyncore.loop(poll_interval, map=self._map, count=1)
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2019-12-10 15:41:23 -04:00
|
|
|
def stop(self):
|
2017-09-07 13:56:24 -03:00
|
|
|
"""
|
|
|
|
Stop the thread by closing the server instance.
|
|
|
|
Wait for the server thread to terminate.
|
|
|
|
"""
|
2021-04-16 09:32:01 -03:00
|
|
|
self._quit = True
|
2020-05-27 19:10:27 -03:00
|
|
|
threading_helper.join_thread(self._thread)
|
2017-09-14 18:40:56 -03:00
|
|
|
self._thread = None
|
2021-04-16 09:32:01 -03:00
|
|
|
self.close()
|
2017-09-07 13:56:24 -03:00
|
|
|
asyncore.close_all(map=self._map, ignore_all=True)
|
2011-05-17 03:15:53 -03:00
|
|
|
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
class ControlMixin(object):
|
|
|
|
"""
|
|
|
|
This mixin is used to start a server on a separate thread, and
|
|
|
|
shut it down programmatically. Request handling is simplified - instead
|
|
|
|
of needing to derive a suitable RequestHandler subclass, you just
|
|
|
|
provide a callable which will be passed each received request to be
|
|
|
|
processed.
|
|
|
|
|
|
|
|
:param handler: A handler callable which will be called with a
|
|
|
|
single parameter - the request - in order to
|
|
|
|
process the request. This handler is called on the
|
|
|
|
server thread, effectively meaning that requests are
|
2021-07-26 19:11:55 -03:00
|
|
|
processed serially. While not quite web scale ;-),
|
2017-09-07 13:56:24 -03:00
|
|
|
this should be fine for testing applications.
|
|
|
|
:param poll_interval: The polling interval in seconds.
|
|
|
|
"""
|
|
|
|
def __init__(self, handler, poll_interval):
|
|
|
|
self._thread = None
|
|
|
|
self.poll_interval = poll_interval
|
|
|
|
self._handler = handler
|
|
|
|
self.ready = threading.Event()
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def start(self):
|
|
|
|
"""
|
|
|
|
Create a daemon thread to run the server, and start it.
|
|
|
|
"""
|
|
|
|
self._thread = t = threading.Thread(target=self.serve_forever,
|
|
|
|
args=(self.poll_interval,))
|
2021-04-12 08:12:36 -03:00
|
|
|
t.daemon = True
|
2017-09-07 13:56:24 -03:00
|
|
|
t.start()
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def serve_forever(self, poll_interval):
|
|
|
|
"""
|
|
|
|
Run the server. Set the ready flag before entering the
|
|
|
|
service loop.
|
|
|
|
"""
|
|
|
|
self.ready.set()
|
|
|
|
super(ControlMixin, self).serve_forever(poll_interval)
|
2017-08-18 19:34:00 -03:00
|
|
|
|
2019-12-10 15:41:23 -04:00
|
|
|
def stop(self):
|
2017-09-07 13:56:24 -03:00
|
|
|
"""
|
|
|
|
Tell the server thread to stop, and wait for it to do so.
|
|
|
|
"""
|
|
|
|
self.shutdown()
|
|
|
|
if self._thread is not None:
|
2020-05-27 19:10:27 -03:00
|
|
|
threading_helper.join_thread(self._thread)
|
2011-05-17 03:15:53 -03:00
|
|
|
self._thread = None
|
2017-09-07 13:56:24 -03:00
|
|
|
self.server_close()
|
|
|
|
self.ready.clear()
|
2011-04-30 17:52:48 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
class TestHTTPServer(ControlMixin, HTTPServer):
|
|
|
|
"""
|
|
|
|
An HTTP server which is controllable using :class:`ControlMixin`.
|
|
|
|
|
|
|
|
:param addr: A tuple with the IP address and port to listen on.
|
|
|
|
:param handler: A handler callable which will be called with a
|
|
|
|
single parameter - the request - in order to
|
|
|
|
process the request.
|
|
|
|
:param poll_interval: The polling interval in seconds.
|
|
|
|
:param log: Pass ``True`` to enable log messages.
|
|
|
|
"""
|
|
|
|
def __init__(self, addr, handler, poll_interval=0.5,
|
|
|
|
log=False, sslctx=None):
|
|
|
|
class DelegatingHTTPRequestHandler(BaseHTTPRequestHandler):
|
|
|
|
def __getattr__(self, name, default=None):
|
|
|
|
if name.startswith('do_'):
|
|
|
|
return self.process_request
|
|
|
|
raise AttributeError(name)
|
|
|
|
|
|
|
|
def process_request(self):
|
|
|
|
self.server._handler(self)
|
|
|
|
|
|
|
|
def log_message(self, format, *args):
|
|
|
|
if log:
|
|
|
|
super(DelegatingHTTPRequestHandler,
|
|
|
|
self).log_message(format, *args)
|
|
|
|
HTTPServer.__init__(self, addr, DelegatingHTTPRequestHandler)
|
|
|
|
ControlMixin.__init__(self, handler, poll_interval)
|
|
|
|
self.sslctx = sslctx
|
|
|
|
|
|
|
|
def get_request(self):
|
|
|
|
try:
|
|
|
|
sock, addr = self.socket.accept()
|
|
|
|
if self.sslctx:
|
|
|
|
sock = self.sslctx.wrap_socket(sock, server_side=True)
|
|
|
|
except OSError as e:
|
|
|
|
# socket errors are silenced by the caller, print them here
|
|
|
|
sys.stderr.write("Got an error:\n%s\n" % e)
|
|
|
|
raise
|
|
|
|
return sock, addr
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
class TestTCPServer(ControlMixin, ThreadingTCPServer):
|
|
|
|
"""
|
|
|
|
A TCP server which is controllable using :class:`ControlMixin`.
|
|
|
|
|
|
|
|
:param addr: A tuple with the IP address and port to listen on.
|
|
|
|
:param handler: A handler callable which will be called with a single
|
|
|
|
parameter - the request - in order to process the request.
|
|
|
|
:param poll_interval: The polling interval in seconds.
|
|
|
|
:bind_and_activate: If True (the default), binds the server and starts it
|
|
|
|
listening. If False, you need to call
|
|
|
|
:meth:`server_bind` and :meth:`server_activate` at
|
|
|
|
some later time before calling :meth:`start`, so that
|
|
|
|
the server will set up the socket and listen on it.
|
|
|
|
"""
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
allow_reuse_address = True
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def __init__(self, addr, handler, poll_interval=0.5,
|
|
|
|
bind_and_activate=True):
|
|
|
|
class DelegatingTCPRequestHandler(StreamRequestHandler):
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def handle(self):
|
|
|
|
self.server._handler(self)
|
|
|
|
ThreadingTCPServer.__init__(self, addr, DelegatingTCPRequestHandler,
|
|
|
|
bind_and_activate)
|
|
|
|
ControlMixin.__init__(self, handler, poll_interval)
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def server_bind(self):
|
|
|
|
super(TestTCPServer, self).server_bind()
|
|
|
|
self.port = self.socket.getsockname()[1]
|
|
|
|
|
|
|
|
class TestUDPServer(ControlMixin, ThreadingUDPServer):
|
|
|
|
"""
|
|
|
|
A UDP server which is controllable using :class:`ControlMixin`.
|
|
|
|
|
|
|
|
:param addr: A tuple with the IP address and port to listen on.
|
|
|
|
:param handler: A handler callable which will be called with a
|
|
|
|
single parameter - the request - in order to
|
|
|
|
process the request.
|
|
|
|
:param poll_interval: The polling interval for shutdown requests,
|
|
|
|
in seconds.
|
|
|
|
:bind_and_activate: If True (the default), binds the server and
|
|
|
|
starts it listening. If False, you need to
|
|
|
|
call :meth:`server_bind` and
|
|
|
|
:meth:`server_activate` at some later time
|
|
|
|
before calling :meth:`start`, so that the server will
|
|
|
|
set up the socket and listen on it.
|
|
|
|
"""
|
|
|
|
def __init__(self, addr, handler, poll_interval=0.5,
|
|
|
|
bind_and_activate=True):
|
|
|
|
class DelegatingUDPRequestHandler(DatagramRequestHandler):
|
2011-05-02 09:17:27 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def handle(self):
|
|
|
|
self.server._handler(self)
|
2011-05-02 10:31:16 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def finish(self):
|
|
|
|
data = self.wfile.getvalue()
|
|
|
|
if data:
|
|
|
|
try:
|
|
|
|
super(DelegatingUDPRequestHandler, self).finish()
|
|
|
|
except OSError:
|
|
|
|
if not self.server._closed:
|
|
|
|
raise
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
ThreadingUDPServer.__init__(self, addr,
|
|
|
|
DelegatingUDPRequestHandler,
|
|
|
|
bind_and_activate)
|
|
|
|
ControlMixin.__init__(self, handler, poll_interval)
|
|
|
|
self._closed = False
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def server_bind(self):
|
|
|
|
super(TestUDPServer, self).server_bind()
|
|
|
|
self.port = self.socket.getsockname()[1]
|
2011-05-17 03:15:53 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
def server_close(self):
|
|
|
|
super(TestUDPServer, self).server_close()
|
|
|
|
self._closed = True
|
2011-05-02 09:17:27 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
if hasattr(socket, "AF_UNIX"):
|
|
|
|
class TestUnixStreamServer(TestTCPServer):
|
|
|
|
address_family = socket.AF_UNIX
|
2014-06-02 09:41:51 -03:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
class TestUnixDatagramServer(TestUDPServer):
|
|
|
|
address_family = socket.AF_UNIX
|
2013-09-27 14:18:28 -03:00
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
# - end of server_helper section
|
2011-04-30 17:52:48 -03:00
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2011-04-30 17:52:48 -03:00
|
|
|
class SMTPHandlerTest(BaseTest):
|
2019-12-10 16:12:26 -04:00
|
|
|
# bpo-14314, bpo-19665, bpo-34092: don't wait forever
|
|
|
|
TIMEOUT = support.LONG_TIMEOUT
|
2017-04-24 19:41:36 -03:00
|
|
|
|
2011-04-30 17:52:48 -03:00
|
|
|
def test_basic(self):
|
2011-05-02 09:17:27 -03:00
|
|
|
sockmap = {}
|
2020-04-25 04:06:29 -03:00
|
|
|
server = TestSMTPServer((socket_helper.HOST, 0), self.process_message, 0.001,
|
2011-05-02 09:17:27 -03:00
|
|
|
sockmap)
|
|
|
|
server.start()
|
2020-04-25 04:06:29 -03:00
|
|
|
addr = (socket_helper.HOST, server.port)
|
2013-12-03 07:28:55 -04:00
|
|
|
h = logging.handlers.SMTPHandler(addr, 'me', 'you', 'Log',
|
|
|
|
timeout=self.TIMEOUT)
|
2011-04-30 17:52:48 -03:00
|
|
|
self.assertEqual(h.toaddrs, ['you'])
|
|
|
|
self.messages = []
|
2015-10-17 12:13:10 -03:00
|
|
|
r = logging.makeLogRecord({'msg': 'Hello \u2713'})
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled = threading.Event()
|
2011-04-30 17:52:48 -03:00
|
|
|
h.handle(r)
|
2018-07-11 07:35:38 -03:00
|
|
|
self.handled.wait(self.TIMEOUT)
|
2011-04-30 17:52:48 -03:00
|
|
|
server.stop()
|
2012-03-15 09:02:08 -03:00
|
|
|
self.assertTrue(self.handled.is_set())
|
2011-04-30 17:52:48 -03:00
|
|
|
self.assertEqual(len(self.messages), 1)
|
|
|
|
peer, mailfrom, rcpttos, data = self.messages[0]
|
|
|
|
self.assertEqual(mailfrom, 'me')
|
|
|
|
self.assertEqual(rcpttos, ['you'])
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertIn('\nSubject: Log\n', data)
|
2015-10-17 12:13:10 -03:00
|
|
|
self.assertTrue(data.endswith('\n\nHello \u2713'))
|
2011-04-30 17:52:48 -03:00
|
|
|
h.close()
|
|
|
|
|
|
|
|
def process_message(self, *args):
|
|
|
|
self.messages.append(args)
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled.set()
|
2011-04-30 17:52:48 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class MemoryHandlerTest(BaseTest):
|
|
|
|
|
|
|
|
"""Tests for the MemoryHandler."""
|
|
|
|
|
|
|
|
# Do not bother with a logger name group.
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^[\w.]+ -> (\w+): (\d+)$"
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
BaseTest.setUp(self)
|
|
|
|
self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING,
|
2016-09-07 21:37:03 -03:00
|
|
|
self.root_hdlr)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.mem_logger = logging.getLogger('mem')
|
|
|
|
self.mem_logger.propagate = 0
|
|
|
|
self.mem_logger.addHandler(self.mem_hdlr)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.mem_hdlr.close()
|
Merged revisions 62021,62029,62035-62038,62043-62044,62052-62053 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62021 | benjamin.peterson | 2008-03-28 18:11:01 -0500 (Fri, 28 Mar 2008) | 2 lines
NIL => NULL
........
r62029 | amaury.forgeotdarc | 2008-03-28 20:42:31 -0500 (Fri, 28 Mar 2008) | 3 lines
Correctly call the base class tearDown();
otherwise running test_logging twice produce the errors we see on all buildbots
........
r62035 | raymond.hettinger | 2008-03-29 05:42:07 -0500 (Sat, 29 Mar 2008) | 1 line
Be explicit about what efficient means.
........
r62036 | georg.brandl | 2008-03-29 06:46:18 -0500 (Sat, 29 Mar 2008) | 2 lines
Fix capitalization.
........
r62037 | amaury.forgeotdarc | 2008-03-29 07:42:54 -0500 (Sat, 29 Mar 2008) | 5 lines
lib2to3 should install a logging handler only when run as a main program,
not when used as a library.
This may please the buildbots, which fail when test_lib2to3 is run before test_logging.
........
r62043 | benjamin.peterson | 2008-03-29 10:24:25 -0500 (Sat, 29 Mar 2008) | 3 lines
#2503 make singletons compared with "is" not == or !=
Thanks to Wummel for the patch
........
r62044 | gerhard.haering | 2008-03-29 14:11:52 -0500 (Sat, 29 Mar 2008) | 2 lines
Documented the lastrowid attribute.
........
r62052 | benjamin.peterson | 2008-03-30 14:35:10 -0500 (Sun, 30 Mar 2008) | 2 lines
Updated README regarding doc formats
........
r62053 | georg.brandl | 2008-03-30 14:41:39 -0500 (Sun, 30 Mar 2008) | 2 lines
The other download formats will be available for 2.6 too.
........
2008-03-30 22:51:45 -03:00
|
|
|
BaseTest.tearDown(self)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def test_flush(self):
|
|
|
|
# The memory handler flushes to its target handler based on specific
|
|
|
|
# criteria (message count and message level).
|
|
|
|
self.mem_logger.debug(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([])
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.mem_logger.info(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([])
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# This will flush because the level is >= logging.WARNING
|
2011-10-26 09:17:20 -03:00
|
|
|
self.mem_logger.warning(self.next_message())
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
lines = [
|
|
|
|
('DEBUG', '1'),
|
|
|
|
('INFO', '2'),
|
|
|
|
('WARNING', '3'),
|
|
|
|
]
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(lines)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
for n in (4, 14):
|
|
|
|
for i in range(9):
|
|
|
|
self.mem_logger.debug(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(lines)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# This will flush because it's the 10th message since the last
|
|
|
|
# flush.
|
|
|
|
self.mem_logger.debug(self.next_message())
|
|
|
|
lines = lines + [('DEBUG', str(i)) for i in range(n, n + 10)]
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(lines)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
self.mem_logger.debug(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines(lines)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2016-09-07 21:37:03 -03:00
|
|
|
def test_flush_on_close(self):
|
|
|
|
"""
|
|
|
|
Test that the flush-on-close configuration works as expected.
|
|
|
|
"""
|
|
|
|
self.mem_logger.debug(self.next_message())
|
|
|
|
self.assert_log_lines([])
|
|
|
|
self.mem_logger.info(self.next_message())
|
|
|
|
self.assert_log_lines([])
|
|
|
|
self.mem_logger.removeHandler(self.mem_hdlr)
|
|
|
|
# Default behaviour is to flush on close. Check that it happens.
|
|
|
|
self.mem_hdlr.close()
|
|
|
|
lines = [
|
|
|
|
('DEBUG', '1'),
|
|
|
|
('INFO', '2'),
|
|
|
|
]
|
|
|
|
self.assert_log_lines(lines)
|
|
|
|
# Now configure for flushing not to be done on close.
|
|
|
|
self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING,
|
|
|
|
self.root_hdlr,
|
|
|
|
False)
|
|
|
|
self.mem_logger.addHandler(self.mem_hdlr)
|
|
|
|
self.mem_logger.debug(self.next_message())
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
self.mem_logger.info(self.next_message())
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
self.mem_logger.removeHandler(self.mem_hdlr)
|
|
|
|
self.mem_hdlr.close()
|
|
|
|
# assert that no new lines have been added
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
|
2022-08-10 14:08:55 -03:00
|
|
|
def test_shutdown_flush_on_close(self):
|
|
|
|
"""
|
|
|
|
Test that the flush-on-close configuration is respected by the
|
|
|
|
shutdown method.
|
|
|
|
"""
|
|
|
|
self.mem_logger.debug(self.next_message())
|
|
|
|
self.assert_log_lines([])
|
|
|
|
self.mem_logger.info(self.next_message())
|
|
|
|
self.assert_log_lines([])
|
|
|
|
# Default behaviour is to flush on close. Check that it happens.
|
|
|
|
logging.shutdown(handlerList=[logging.weakref.ref(self.mem_hdlr)])
|
|
|
|
lines = [
|
|
|
|
('DEBUG', '1'),
|
|
|
|
('INFO', '2'),
|
|
|
|
]
|
|
|
|
self.assert_log_lines(lines)
|
|
|
|
# Now configure for flushing not to be done on close.
|
|
|
|
self.mem_hdlr = logging.handlers.MemoryHandler(10, logging.WARNING,
|
|
|
|
self.root_hdlr,
|
|
|
|
False)
|
|
|
|
self.mem_logger.addHandler(self.mem_hdlr)
|
|
|
|
self.mem_logger.debug(self.next_message())
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
self.mem_logger.info(self.next_message())
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
# assert that no new lines have been added after shutdown
|
|
|
|
logging.shutdown(handlerList=[logging.weakref.ref(self.mem_hdlr)])
|
|
|
|
self.assert_log_lines(lines) # no change
|
|
|
|
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2020-08-16 12:10:13 -03:00
|
|
|
def test_race_between_set_target_and_flush(self):
|
|
|
|
class MockRaceConditionHandler:
|
|
|
|
def __init__(self, mem_hdlr):
|
|
|
|
self.mem_hdlr = mem_hdlr
|
2020-10-11 19:37:20 -03:00
|
|
|
self.threads = []
|
2020-08-16 12:10:13 -03:00
|
|
|
|
|
|
|
def removeTarget(self):
|
|
|
|
self.mem_hdlr.setTarget(None)
|
|
|
|
|
|
|
|
def handle(self, msg):
|
2020-10-11 19:37:20 -03:00
|
|
|
thread = threading.Thread(target=self.removeTarget)
|
|
|
|
self.threads.append(thread)
|
|
|
|
thread.start()
|
2020-08-16 12:10:13 -03:00
|
|
|
|
|
|
|
target = MockRaceConditionHandler(self.mem_hdlr)
|
2020-10-11 19:37:20 -03:00
|
|
|
try:
|
|
|
|
self.mem_hdlr.setTarget(target)
|
2020-08-16 12:10:13 -03:00
|
|
|
|
2020-10-11 19:37:20 -03:00
|
|
|
for _ in range(10):
|
|
|
|
time.sleep(0.005)
|
|
|
|
self.mem_logger.info("not flushed")
|
|
|
|
self.mem_logger.warning("flushed")
|
|
|
|
finally:
|
|
|
|
for thread in target.threads:
|
|
|
|
threading_helper.join_thread(thread)
|
2020-08-16 12:10:13 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
class ExceptionFormatter(logging.Formatter):
|
|
|
|
"""A special exception formatter."""
|
|
|
|
def formatException(self, ei):
|
|
|
|
return "Got a [%s]" % ei[0].__name__
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
def closeFileHandler(h, fn):
|
|
|
|
h.close()
|
|
|
|
os.remove(fn)
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class ConfigFileTest(BaseTest):
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
"""Reading logging config from a .ini-style config file."""
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
2020-06-30 10:46:06 -03:00
|
|
|
check_no_resource_warning = warnings_helper.check_no_resource_warning
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^(\w+) \+\+ (\w+)$"
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# config0 is a standard configuration.
|
|
|
|
config0 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatters]
|
|
|
|
keys=form1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=hand1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# config1 adds a little to the standard configuration.
|
|
|
|
config1 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root,parser
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatters]
|
|
|
|
keys=form1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[logger_parser]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=hand1
|
|
|
|
propagate=1
|
|
|
|
qualname=compiler.parser
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
2011-03-07 13:49:33 -04:00
|
|
|
# config1a moves the handler to the root.
|
|
|
|
config1a = """
|
|
|
|
[loggers]
|
|
|
|
keys=root,parser
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=hand1
|
|
|
|
|
|
|
|
[logger_parser]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=
|
|
|
|
propagate=1
|
|
|
|
qualname=compiler.parser
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# config2 has a subtle configuration error that should be reported
|
|
|
|
config2 = config1.replace("sys.stdout", "sys.stbout")
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# config3 has a less subtle configuration error
|
|
|
|
config3 = config1.replace("formatter=form1", "formatter=misspelled_name")
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# config4 specifies a custom formatter class to be loaded
|
|
|
|
config4 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatters]
|
|
|
|
keys=form1
|
2003-01-02 10:56:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[logger_root]
|
|
|
|
level=NOTSET
|
|
|
|
handlers=hand1
|
2003-01-02 10:56:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
[formatter_form1]
|
|
|
|
class=""" + __name__ + """.ExceptionFormatter
|
|
|
|
format=%(levelname)s:%(name)s:%(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60873 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r60850 | amaury.forgeotdarc | 2008-02-16 01:16:50 +0100 (Sat, 16 Feb 2008) | 3 lines
mmap.PROT_READ does not exists on win32;
Skip this test created by r60830.
........
r60851 | raymond.hettinger | 2008-02-16 02:22:54 +0100 (Sat, 16 Feb 2008) | 1 line
Add __all__ to logging module.
........
r60855 | georg.brandl | 2008-02-16 10:37:32 +0100 (Sat, 16 Feb 2008) | 2 lines
#2120: broken links in advocacy document.
........
r60860 | amaury.forgeotdarc | 2008-02-16 15:34:57 +0100 (Sat, 16 Feb 2008) | 23 lines
Crashers of the day: Py_CLEAR must be used when there is a chance that the
function can be called recursively.
This was discussed in issue1020188.
In python codebase, all occurrences of Py_[X]DECREF(xxx->yyy) are suspect,
except when they appear in tp_new or tp_dealloc functions, or when
the member cannot be of a user-defined class.
Note that tp_init is not safe.
I do have a (crashing) example for every changed line.
Is it worth adding them to the test suite?
Example:
class SpecialStr(str):
def __del__(self):
s.close()
import cStringIO
s = cStringIO.StringIO(SpecialStr("text"))
s.close() # Segfault
........
r60871 | amaury.forgeotdarc | 2008-02-16 21:55:24 +0100 (Sat, 16 Feb 2008) | 3 lines
Prevent a crash with nested scopes, again caused by calling Py_DECREF when the pointer
is still present in the containing structure.
........
r60872 | brett.cannon | 2008-02-17 02:59:18 +0100 (Sun, 17 Feb 2008) | 4 lines
Move test_logging over to doctest.
Thanks to Christopher White from GHOP.
........
r60873 | georg.brandl | 2008-02-17 12:33:38 +0100 (Sun, 17 Feb 2008) | 2 lines
#2131: note that codecs.open() always opens files in binary mode.
........
2008-02-17 09:31:39 -04:00
|
|
|
|
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines
Apply patch for issue 3090: ARCHFLAGS parsing incorrect
........
r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines
#3045: fix pydoc behavior for TEMP path with spaces.
........
r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines
#1608818: errno can get set by every call to readdir().
........
r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines
#3305: self->stream can be NULL.
........
r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines
#3345: fix docstring.
........
r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines
#3312: fix two sqlite3 crashes.
........
r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines
#3388: add a paragraph about using "with" for file objects.
........
r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines
news note for r63052
........
r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines
Fix issue 3395, update _debugInfo to be _debug_info
........
r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
........
r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
........
r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
........
r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
........
r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
........
r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
........
r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
........
r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
........
r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
........
r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
........
r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
........
r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
........
r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
........
r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
........
r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
........
r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
........
r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line
Fix a couple of names in error messages that were wrong
........
r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line
Fix misspeeld method name (negative)
........
r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines
Increment version number in NEWS file, and move items that were added after 2.6b2.
(I thought there was a script to automate this kind of updates)
........
r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
........
r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line
don't use assert statement
........
r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix buglet in fix for issue3381
........
r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix build issue on OSX 10.4, somehow this wasn't committed before.
........
r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line
Remove out-of-date section on Exact/Inexact.
........
r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line
Tuples now have both count() and index().
........
r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line
Fix credits for math.sum()
........
r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line
One more attribution.
........
r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line
remove unneeded import
........
r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line
use isinstance
........
2008-07-23 13:10:53 -03:00
|
|
|
# config5 specifies a custom handler class to be loaded
|
|
|
|
config5 = config1.replace('class=StreamHandler', 'class=logging.StreamHandler')
|
|
|
|
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
# config6 uses ', ' delimiters in the handlers and formatters sections
|
|
|
|
config6 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root,parser
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1, hand2
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1, form2
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=
|
|
|
|
|
|
|
|
[logger_parser]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=hand1
|
|
|
|
propagate=1
|
|
|
|
qualname=compiler.parser
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
|
|
|
|
|
|
|
[handler_hand2]
|
Merged revisions 66337,66347,66350,66352,66358 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66337 | vinay.sajip | 2008-09-09 08:42:08 -0500 (Tue, 09 Sep 2008) | 1 line
Issue #3809: Fixed spurious 'test.blah' file left behind by test_logging.
........
r66347 | georg.brandl | 2008-09-09 14:26:00 -0500 (Tue, 09 Sep 2008) | 2 lines
Fix varname in docstring. #3822.
........
r66350 | georg.brandl | 2008-09-09 15:28:31 -0500 (Tue, 09 Sep 2008) | 2 lines
#3472: update Mac-bundled Python version info.
........
r66352 | benjamin.peterson | 2008-09-09 15:55:01 -0500 (Tue, 09 Sep 2008) | 4 lines
Fix #3634 invalid return value from _weakref.ref(Exception).__init__
Reviewers: Amaury, Antoine, Benjamin
........
r66358 | benjamin.peterson | 2008-09-09 18:16:48 -0500 (Tue, 09 Sep 2008) | 1 line
use the latest pygments version
........
2008-09-10 18:57:34 -03:00
|
|
|
class=StreamHandler
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
Merged revisions 66337,66347,66350,66352,66358 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66337 | vinay.sajip | 2008-09-09 08:42:08 -0500 (Tue, 09 Sep 2008) | 1 line
Issue #3809: Fixed spurious 'test.blah' file left behind by test_logging.
........
r66347 | georg.brandl | 2008-09-09 14:26:00 -0500 (Tue, 09 Sep 2008) | 2 lines
Fix varname in docstring. #3822.
........
r66350 | georg.brandl | 2008-09-09 15:28:31 -0500 (Tue, 09 Sep 2008) | 2 lines
#3472: update Mac-bundled Python version info.
........
r66352 | benjamin.peterson | 2008-09-09 15:55:01 -0500 (Tue, 09 Sep 2008) | 4 lines
Fix #3634 invalid return value from _weakref.ref(Exception).__init__
Reviewers: Amaury, Antoine, Benjamin
........
r66358 | benjamin.peterson | 2008-09-09 18:16:48 -0500 (Tue, 09 Sep 2008) | 1 line
use the latest pygments version
........
2008-09-10 18:57:34 -03:00
|
|
|
args=(sys.stderr,)
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
datefmt=
|
|
|
|
|
|
|
|
[formatter_form2]
|
|
|
|
format=%(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
|
|
|
|
2017-08-02 17:44:28 -03:00
|
|
|
# config7 adds a compiler logger, and uses kwargs instead of args.
|
2011-03-07 13:49:33 -04:00
|
|
|
config7 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root,parser,compiler
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=hand1
|
|
|
|
|
|
|
|
[logger_compiler]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=
|
|
|
|
propagate=1
|
|
|
|
qualname=compiler
|
|
|
|
|
|
|
|
[logger_parser]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=
|
|
|
|
propagate=1
|
|
|
|
qualname=compiler.parser
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
2017-08-02 17:44:28 -03:00
|
|
|
kwargs={'stream': sys.stdout,}
|
2011-03-07 13:49:33 -04:00
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
datefmt=
|
|
|
|
"""
|
|
|
|
|
2018-07-02 05:57:46 -03:00
|
|
|
# config 8, check for resource warning
|
|
|
|
config8 = r"""
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=file
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=file
|
|
|
|
|
|
|
|
[handler_file]
|
|
|
|
class=FileHandler
|
|
|
|
level=DEBUG
|
|
|
|
args=("{tempfile}",)
|
2021-04-28 23:34:56 -03:00
|
|
|
kwargs={{"encoding": "utf-8"}}
|
2018-07-02 05:57:46 -03:00
|
|
|
"""
|
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
|
|
|
|
config9 = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=WARNING
|
|
|
|
handlers=hand1
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
level=NOTSET
|
|
|
|
formatter=form1
|
|
|
|
args=(sys.stdout,)
|
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(message)s ++ %(customfield)s
|
|
|
|
defaults={"customfield": "defaultvalue"}
|
|
|
|
"""
|
|
|
|
|
2013-03-23 08:18:45 -03:00
|
|
|
disable_test = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=screen
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
level=DEBUG
|
|
|
|
handlers=screen
|
|
|
|
|
|
|
|
[handler_screen]
|
|
|
|
level=DEBUG
|
|
|
|
class=StreamHandler
|
|
|
|
args=(sys.stdout,)
|
|
|
|
formatter=
|
|
|
|
"""
|
|
|
|
|
|
|
|
def apply_config(self, conf, **kwargs):
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
file = io.StringIO(textwrap.dedent(conf))
|
2021-04-28 23:34:56 -03:00
|
|
|
logging.config.fileConfig(file, encoding="utf-8", **kwargs)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def test_config0_ok(self):
|
|
|
|
# A simple config file which overrides the default settings.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.apply_config(self.config0)
|
|
|
|
logger = logging.getLogger()
|
|
|
|
# Won't output anything
|
|
|
|
logger.info(self.next_message())
|
|
|
|
# Outputs a message
|
|
|
|
logger.error(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([])
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2012-10-09 05:06:03 -03:00
|
|
|
def test_config0_using_cp_ok(self):
|
|
|
|
# A simple config file which overrides the default settings.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2012-10-09 05:06:03 -03:00
|
|
|
file = io.StringIO(textwrap.dedent(self.config0))
|
|
|
|
cp = configparser.ConfigParser()
|
|
|
|
cp.read_file(file)
|
|
|
|
logging.config.fileConfig(cp)
|
|
|
|
logger = logging.getLogger()
|
|
|
|
# Won't output anything
|
|
|
|
logger.info(self.next_message())
|
|
|
|
# Outputs a message
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines
Apply patch for issue 3090: ARCHFLAGS parsing incorrect
........
r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines
#3045: fix pydoc behavior for TEMP path with spaces.
........
r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines
#1608818: errno can get set by every call to readdir().
........
r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines
#3305: self->stream can be NULL.
........
r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines
#3345: fix docstring.
........
r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines
#3312: fix two sqlite3 crashes.
........
r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines
#3388: add a paragraph about using "with" for file objects.
........
r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines
news note for r63052
........
r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines
Fix issue 3395, update _debugInfo to be _debug_info
........
r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
........
r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
........
r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
........
r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
........
r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
........
r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
........
r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
........
r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
........
r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
........
r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
........
r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
........
r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
........
r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
........
r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
........
r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
........
r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
........
r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line
Fix a couple of names in error messages that were wrong
........
r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line
Fix misspeeld method name (negative)
........
r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines
Increment version number in NEWS file, and move items that were added after 2.6b2.
(I thought there was a script to automate this kind of updates)
........
r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
........
r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line
don't use assert statement
........
r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix buglet in fix for issue3381
........
r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix build issue on OSX 10.4, somehow this wasn't committed before.
........
r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line
Remove out-of-date section on Exact/Inexact.
........
r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line
Tuples now have both count() and index().
........
r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line
Fix credits for math.sum()
........
r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line
One more attribution.
........
r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line
remove unneeded import
........
r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line
use isinstance
........
2008-07-23 13:10:53 -03:00
|
|
|
def test_config1_ok(self, config=config1):
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# A config file defining a sub-parser as well.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines
Apply patch for issue 3090: ARCHFLAGS parsing incorrect
........
r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines
#3045: fix pydoc behavior for TEMP path with spaces.
........
r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines
#1608818: errno can get set by every call to readdir().
........
r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines
#3305: self->stream can be NULL.
........
r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines
#3345: fix docstring.
........
r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines
#3312: fix two sqlite3 crashes.
........
r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines
#3388: add a paragraph about using "with" for file objects.
........
r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines
news note for r63052
........
r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines
Fix issue 3395, update _debugInfo to be _debug_info
........
r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
........
r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
........
r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
........
r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
........
r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
........
r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
........
r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
........
r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
........
r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
........
r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
........
r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
........
r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
........
r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
........
r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
........
r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
........
r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
........
r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line
Fix a couple of names in error messages that were wrong
........
r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line
Fix misspeeld method name (negative)
........
r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines
Increment version number in NEWS file, and move items that were added after 2.6b2.
(I thought there was a script to automate this kind of updates)
........
r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
........
r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line
don't use assert statement
........
r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix buglet in fix for issue3381
........
r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix build issue on OSX 10.4, somehow this wasn't committed before.
........
r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line
Remove out-of-date section on Exact/Inexact.
........
r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line
Tuples now have both count() and index().
........
r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line
Fix credits for math.sum()
........
r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line
One more attribution.
........
r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line
remove unneeded import
........
r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line
use isinstance
........
2008-07-23 13:10:53 -03:00
|
|
|
self.apply_config(config)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([])
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def test_config2_failure(self):
|
|
|
|
# A simple config file which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config2)
|
|
|
|
|
|
|
|
def test_config3_failure(self):
|
|
|
|
# A simple config file which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config3)
|
|
|
|
|
|
|
|
def test_config4_ok(self):
|
|
|
|
# A config file specifying a custom formatter class.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.apply_config(self.config4)
|
|
|
|
logger = logging.getLogger()
|
|
|
|
try:
|
|
|
|
raise RuntimeError()
|
|
|
|
except RuntimeError:
|
|
|
|
logging.exception("just testing")
|
|
|
|
sys.stdout.seek(0)
|
2010-11-20 15:04:17 -04:00
|
|
|
self.assertEqual(output.getvalue(),
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
"ERROR:root:just testing\nGot a [RuntimeError]\n")
|
|
|
|
# Original logger output is empty
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([])
|
2003-04-25 11:22:00 -03:00
|
|
|
|
Merged revisions 65012,65035,65037-65040,65048,65057,65077,65091-65095,65097-65099,65127-65128,65131,65133-65136,65139,65149-65151,65155,65158-65159,65176-65178,65183-65184,65187-65190,65192,65194 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65012 | jesse.noller | 2008-07-16 15:24:06 +0200 (Wed, 16 Jul 2008) | 2 lines
Apply patch for issue 3090: ARCHFLAGS parsing incorrect
........
r65035 | georg.brandl | 2008-07-16 23:19:28 +0200 (Wed, 16 Jul 2008) | 2 lines
#3045: fix pydoc behavior for TEMP path with spaces.
........
r65037 | georg.brandl | 2008-07-16 23:31:41 +0200 (Wed, 16 Jul 2008) | 2 lines
#1608818: errno can get set by every call to readdir().
........
r65038 | georg.brandl | 2008-07-17 00:04:20 +0200 (Thu, 17 Jul 2008) | 2 lines
#3305: self->stream can be NULL.
........
r65039 | georg.brandl | 2008-07-17 00:09:17 +0200 (Thu, 17 Jul 2008) | 2 lines
#3345: fix docstring.
........
r65040 | georg.brandl | 2008-07-17 00:33:18 +0200 (Thu, 17 Jul 2008) | 2 lines
#3312: fix two sqlite3 crashes.
........
r65048 | georg.brandl | 2008-07-17 01:35:54 +0200 (Thu, 17 Jul 2008) | 2 lines
#3388: add a paragraph about using "with" for file objects.
........
r65057 | gregory.p.smith | 2008-07-17 05:13:05 +0200 (Thu, 17 Jul 2008) | 2 lines
news note for r63052
........
r65077 | jesse.noller | 2008-07-17 23:01:05 +0200 (Thu, 17 Jul 2008) | 3 lines
Fix issue 3395, update _debugInfo to be _debug_info
........
r65091 | ronald.oussoren | 2008-07-18 07:48:03 +0200 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
........
r65092 | vinay.sajip | 2008-07-18 10:59:06 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65093 | vinay.sajip | 2008-07-18 11:00:00 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65094 | vinay.sajip | 2008-07-18 11:00:35 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65095 | vinay.sajip | 2008-07-18 11:01:10 +0200 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
........
r65097 | georg.brandl | 2008-07-18 12:20:59 +0200 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
........
r65098 | georg.brandl | 2008-07-18 12:29:30 +0200 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
........
r65099 | georg.brandl | 2008-07-18 13:15:06 +0200 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
........
r65127 | raymond.hettinger | 2008-07-19 02:42:03 +0200 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
........
r65128 | raymond.hettinger | 2008-07-19 02:43:00 +0200 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
........
r65131 | georg.brandl | 2008-07-19 12:08:55 +0200 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
........
r65133 | georg.brandl | 2008-07-19 14:39:10 +0200 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
........
r65134 | georg.brandl | 2008-07-19 14:46:12 +0200 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
........
r65135 | georg.brandl | 2008-07-19 15:00:22 +0200 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
........
r65136 | georg.brandl | 2008-07-19 15:09:42 +0200 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
........
r65139 | georg.brandl | 2008-07-19 15:48:44 +0200 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
........
r65149 | raymond.hettinger | 2008-07-20 01:21:57 +0200 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
........
r65150 | raymond.hettinger | 2008-07-20 01:58:47 +0200 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
........
r65151 | gregory.p.smith | 2008-07-20 02:22:08 +0200 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
........
r65155 | georg.brandl | 2008-07-20 13:50:29 +0200 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
........
r65158 | neal.norwitz | 2008-07-20 21:35:23 +0200 (Sun, 20 Jul 2008) | 1 line
Fix a couple of names in error messages that were wrong
........
r65159 | neal.norwitz | 2008-07-20 22:39:36 +0200 (Sun, 20 Jul 2008) | 1 line
Fix misspeeld method name (negative)
........
r65176 | amaury.forgeotdarc | 2008-07-21 23:36:24 +0200 (Mon, 21 Jul 2008) | 4 lines
Increment version number in NEWS file, and move items that were added after 2.6b2.
(I thought there was a script to automate this kind of updates)
........
r65177 | amaury.forgeotdarc | 2008-07-22 00:00:38 +0200 (Tue, 22 Jul 2008) | 5 lines
Issue2378: pdb would delete free variables when stepping into a class statement.
The problem was introduced by r53954, the correction is to restore the symmetry between
PyFrame_FastToLocals and PyFrame_LocalsToFast
........
r65178 | benjamin.peterson | 2008-07-22 00:05:34 +0200 (Tue, 22 Jul 2008) | 1 line
don't use assert statement
........
r65183 | ronald.oussoren | 2008-07-22 09:06:00 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix buglet in fix for issue3381
........
r65184 | ronald.oussoren | 2008-07-22 09:06:33 +0200 (Tue, 22 Jul 2008) | 2 lines
Fix build issue on OSX 10.4, somehow this wasn't committed before.
........
r65187 | raymond.hettinger | 2008-07-22 20:54:02 +0200 (Tue, 22 Jul 2008) | 1 line
Remove out-of-date section on Exact/Inexact.
........
r65188 | raymond.hettinger | 2008-07-22 21:00:47 +0200 (Tue, 22 Jul 2008) | 1 line
Tuples now have both count() and index().
........
r65189 | raymond.hettinger | 2008-07-22 21:03:05 +0200 (Tue, 22 Jul 2008) | 1 line
Fix credits for math.sum()
........
r65190 | raymond.hettinger | 2008-07-22 21:18:50 +0200 (Tue, 22 Jul 2008) | 1 line
One more attribution.
........
r65192 | benjamin.peterson | 2008-07-23 01:44:37 +0200 (Wed, 23 Jul 2008) | 1 line
remove unneeded import
........
r65194 | benjamin.peterson | 2008-07-23 15:25:06 +0200 (Wed, 23 Jul 2008) | 1 line
use isinstance
........
2008-07-23 13:10:53 -03:00
|
|
|
def test_config5_ok(self):
|
|
|
|
self.test_config1_ok(config=self.config5)
|
2003-01-02 10:56:39 -04:00
|
|
|
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
def test_config6_ok(self):
|
|
|
|
self.test_config1_ok(config=self.config6)
|
|
|
|
|
2011-03-07 13:49:33 -04:00
|
|
|
def test_config7_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2011-03-07 13:49:33 -04:00
|
|
|
self.apply_config(self.config1a)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# See issue #11424. compiler-hyphenated sorts
|
|
|
|
# between compiler and compiler.xyz and this
|
|
|
|
# was preventing compiler.xyz from being included
|
|
|
|
# in the child loggers of compiler because of an
|
|
|
|
# overzealous loop termination condition.
|
|
|
|
hyphenated = logging.getLogger('compiler-hyphenated')
|
|
|
|
# All will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
hyphenated.critical(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
('CRITICAL', '3'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2011-03-07 13:49:33 -04:00
|
|
|
self.apply_config(self.config7)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
logger = logging.getLogger("compiler.lexer")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
# Will not appear
|
|
|
|
hyphenated.critical(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '4'),
|
|
|
|
('ERROR', '5'),
|
|
|
|
('INFO', '6'),
|
|
|
|
('ERROR', '7'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
2018-07-02 05:57:46 -03:00
|
|
|
def test_config8_ok(self):
|
|
|
|
|
2021-04-29 08:37:32 -03:00
|
|
|
with self.check_no_resource_warning():
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file(".log", "test_logging-X-")
|
2018-07-02 05:57:46 -03:00
|
|
|
|
|
|
|
# Replace single backslash with double backslash in windows
|
|
|
|
# to avoid unicode error during string formatting
|
|
|
|
if os.name == "nt":
|
|
|
|
fn = fn.replace("\\", "\\\\")
|
|
|
|
|
|
|
|
config8 = self.config8.format(tempfile=fn)
|
|
|
|
|
|
|
|
self.apply_config(config8)
|
|
|
|
self.apply_config(config8)
|
|
|
|
|
|
|
|
handler = logging.root.handlers[0]
|
2022-06-07 05:20:35 -03:00
|
|
|
self.addCleanup(closeFileHandler, handler, fn)
|
2018-07-02 05:57:46 -03:00
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
def test_config9_ok(self):
|
|
|
|
self.apply_config(self.config9)
|
|
|
|
formatter = logging.root.handlers[0].formatter
|
|
|
|
result = formatter.format(logging.makeLogRecord({'msg': 'test'}))
|
|
|
|
self.assertEqual(result, 'test ++ defaultvalue')
|
|
|
|
result = formatter.format(logging.makeLogRecord(
|
|
|
|
{'msg': 'test', 'customfield': "customvalue"}))
|
|
|
|
self.assertEqual(result, 'test ++ customvalue')
|
|
|
|
|
|
|
|
|
2013-03-23 08:18:45 -03:00
|
|
|
def test_logger_disabling(self):
|
|
|
|
self.apply_config(self.disable_test)
|
2013-09-14 16:16:39 -03:00
|
|
|
logger = logging.getLogger('some_pristine_logger')
|
2013-03-23 08:18:45 -03:00
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
self.apply_config(self.disable_test)
|
|
|
|
self.assertTrue(logger.disabled)
|
|
|
|
self.apply_config(self.disable_test, disable_existing_loggers=False)
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
|
2019-10-31 05:06:25 -03:00
|
|
|
def test_config_set_handler_names(self):
|
|
|
|
test_config = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
handlers=hand1
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
formatter=form1
|
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
"""
|
|
|
|
self.apply_config(test_config)
|
2019-11-07 06:13:36 -04:00
|
|
|
self.assertEqual(logging.getLogger().handlers[0].name, 'hand1')
|
2019-10-31 05:06:25 -03:00
|
|
|
|
2023-05-18 01:20:47 -03:00
|
|
|
def test_exception_if_confg_file_is_invalid(self):
|
|
|
|
test_config = """
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=hand1
|
|
|
|
|
|
|
|
[formatters]
|
|
|
|
keys=form1
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
handlers=hand1
|
|
|
|
|
|
|
|
[handler_hand1]
|
|
|
|
class=StreamHandler
|
|
|
|
formatter=form1
|
|
|
|
|
|
|
|
[formatter_form1]
|
|
|
|
format=%(levelname)s ++ %(message)s
|
|
|
|
|
|
|
|
prince
|
|
|
|
"""
|
|
|
|
|
|
|
|
file = io.StringIO(textwrap.dedent(test_config))
|
2023-05-20 19:26:49 -03:00
|
|
|
self.assertRaises(RuntimeError, logging.config.fileConfig, file)
|
2023-05-18 01:20:47 -03:00
|
|
|
|
|
|
|
def test_exception_if_confg_file_is_empty(self):
|
|
|
|
fd, fn = tempfile.mkstemp(prefix='test_empty_', suffix='.ini')
|
|
|
|
os.close(fd)
|
2023-05-20 19:26:49 -03:00
|
|
|
self.assertRaises(RuntimeError, logging.config.fileConfig, fn)
|
2023-05-18 01:20:47 -03:00
|
|
|
os.remove(fn)
|
|
|
|
|
|
|
|
def test_exception_if_config_file_does_not_exist(self):
|
|
|
|
self.assertRaises(FileNotFoundError, logging.config.fileConfig, 'filenotfound')
|
|
|
|
|
2018-06-08 08:02:48 -03:00
|
|
|
def test_defaults_do_no_interpolation(self):
|
|
|
|
"""bpo-33802 defaults should not get interpolated"""
|
|
|
|
ini = textwrap.dedent("""
|
|
|
|
[formatters]
|
|
|
|
keys=default
|
|
|
|
|
|
|
|
[formatter_default]
|
|
|
|
|
|
|
|
[handlers]
|
|
|
|
keys=console
|
|
|
|
|
|
|
|
[handler_console]
|
|
|
|
class=logging.StreamHandler
|
|
|
|
args=tuple()
|
|
|
|
|
|
|
|
[loggers]
|
|
|
|
keys=root
|
|
|
|
|
|
|
|
[logger_root]
|
|
|
|
formatter=default
|
|
|
|
handlers=console
|
|
|
|
""").strip()
|
|
|
|
fd, fn = tempfile.mkstemp(prefix='test_logging_', suffix='.ini')
|
|
|
|
try:
|
|
|
|
os.write(fd, ini.encode('ascii'))
|
|
|
|
os.close(fd)
|
|
|
|
logging.config.fileConfig(
|
|
|
|
fn,
|
2021-04-28 23:34:56 -03:00
|
|
|
encoding="utf-8",
|
2018-06-08 08:02:48 -03:00
|
|
|
defaults=dict(
|
|
|
|
version=1,
|
|
|
|
disable_existing_loggers=False,
|
|
|
|
formatters={
|
|
|
|
"generic": {
|
|
|
|
"format": "%(asctime)s [%(process)d] [%(levelname)s] %(message)s",
|
|
|
|
"datefmt": "[%Y-%m-%d %H:%M:%S %z]",
|
|
|
|
"class": "logging.Formatter"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
)
|
|
|
|
finally:
|
|
|
|
os.unlink(fn)
|
|
|
|
|
2006-01-16 17:24:38 -04:00
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class SocketHandlerTest(BaseTest):
|
2006-01-16 17:24:38 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
"""Test for SocketHandler objects."""
|
2006-01-16 17:24:38 -04:00
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
server_class = TestTCPServer
|
|
|
|
address = ('localhost', 0)
|
2013-09-27 14:18:28 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
def setUp(self):
|
|
|
|
"""Set up a TCP server to receive log messages, and a SocketHandler
|
|
|
|
pointing to that server's address and port."""
|
|
|
|
BaseTest.setUp(self)
|
2017-01-09 12:54:12 -04:00
|
|
|
# Issue #29177: deal with errors that happen during setup
|
|
|
|
self.server = self.sock_hdlr = self.server_exception = None
|
|
|
|
try:
|
|
|
|
self.server = server = self.server_class(self.address,
|
|
|
|
self.handle_socket, 0.01)
|
|
|
|
server.start()
|
|
|
|
# Uncomment next line to test error recovery in setUp()
|
|
|
|
# raise OSError('dummy error raised')
|
|
|
|
except OSError as e:
|
|
|
|
self.server_exception = e
|
|
|
|
return
|
2011-05-02 09:17:27 -03:00
|
|
|
server.ready.wait()
|
2013-09-27 14:18:28 -03:00
|
|
|
hcls = logging.handlers.SocketHandler
|
|
|
|
if isinstance(server.server_address, tuple):
|
|
|
|
self.sock_hdlr = hcls('localhost', server.port)
|
|
|
|
else:
|
|
|
|
self.sock_hdlr = hcls(server.server_address, None)
|
2011-05-02 09:17:27 -03:00
|
|
|
self.log_output = ''
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
self.root_logger.removeHandler(self.root_logger.handlers[0])
|
|
|
|
self.root_logger.addHandler(self.sock_hdlr)
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled = threading.Semaphore(0)
|
2006-01-16 17:24:38 -04:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
def tearDown(self):
|
|
|
|
"""Shutdown the TCP server."""
|
|
|
|
try:
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.sock_hdlr:
|
|
|
|
self.root_logger.removeHandler(self.sock_hdlr)
|
|
|
|
self.sock_hdlr.close()
|
2017-09-13 05:47:22 -03:00
|
|
|
if self.server:
|
2019-12-10 15:41:23 -04:00
|
|
|
self.server.stop()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
finally:
|
|
|
|
BaseTest.tearDown(self)
|
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
def handle_socket(self, request):
|
|
|
|
conn = request.connection
|
|
|
|
while True:
|
|
|
|
chunk = conn.recv(4)
|
|
|
|
if len(chunk) < 4:
|
|
|
|
break
|
|
|
|
slen = struct.unpack(">L", chunk)[0]
|
|
|
|
chunk = conn.recv(slen)
|
|
|
|
while len(chunk) < slen:
|
|
|
|
chunk = chunk + conn.recv(slen - len(chunk))
|
|
|
|
obj = pickle.loads(chunk)
|
|
|
|
record = logging.makeLogRecord(obj)
|
|
|
|
self.log_output += record.msg + '\n'
|
|
|
|
self.handled.release()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
|
|
|
def test_output(self):
|
|
|
|
# The log message sent to the SocketHandler is properly received.
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server_exception:
|
|
|
|
self.skipTest(self.server_exception)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logger = logging.getLogger("tcp")
|
|
|
|
logger.error("spam")
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled.acquire()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
logger.debug("eggs")
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled.acquire()
|
|
|
|
self.assertEqual(self.log_output, "spam\neggs\n")
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2011-04-28 08:04:58 -03:00
|
|
|
def test_noserver(self):
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server_exception:
|
|
|
|
self.skipTest(self.server_exception)
|
2012-10-21 12:18:27 -03:00
|
|
|
# Avoid timing-related failures due to SocketHandler's own hard-wired
|
|
|
|
# one-second timeout on socket.create_connection() (issue #16264).
|
|
|
|
self.sock_hdlr.retryStart = 2.5
|
2011-04-28 08:04:58 -03:00
|
|
|
# Kill the server
|
2019-12-10 15:41:23 -04:00
|
|
|
self.server.stop()
|
2012-10-21 12:18:27 -03:00
|
|
|
# The logging call should try to connect, which should fail
|
2011-04-28 08:04:58 -03:00
|
|
|
try:
|
|
|
|
raise RuntimeError('Deliberate mistake')
|
|
|
|
except RuntimeError:
|
|
|
|
self.root_logger.exception('Never sent')
|
|
|
|
self.root_logger.error('Never sent, either')
|
|
|
|
now = time.time()
|
2012-10-17 08:24:27 -03:00
|
|
|
self.assertGreater(self.sock_hdlr.retryTime, now)
|
2011-04-28 08:04:58 -03:00
|
|
|
time.sleep(self.sock_hdlr.retryTime - now + 0.001)
|
|
|
|
self.root_logger.error('Nor this')
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
|
2014-06-02 09:41:51 -03:00
|
|
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
2013-09-27 14:18:28 -03:00
|
|
|
class UnixSocketHandlerTest(SocketHandlerTest):
|
|
|
|
|
|
|
|
"""Test for SocketHandler with unix sockets."""
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
if hasattr(socket, "AF_UNIX"):
|
2013-09-27 15:08:24 -03:00
|
|
|
server_class = TestUnixStreamServer
|
2013-09-27 14:18:28 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
# override the definition in the base class
|
2022-06-17 08:16:51 -03:00
|
|
|
self.address = socket_helper.create_unix_domain_name()
|
|
|
|
self.addCleanup(os_helper.unlink, self.address)
|
2013-09-27 14:18:28 -03:00
|
|
|
SocketHandlerTest.setUp(self)
|
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2011-05-02 09:17:27 -03:00
|
|
|
class DatagramHandlerTest(BaseTest):
|
|
|
|
|
|
|
|
"""Test for DatagramHandler."""
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
server_class = TestUDPServer
|
|
|
|
address = ('localhost', 0)
|
2013-09-27 14:18:28 -03:00
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
def setUp(self):
|
|
|
|
"""Set up a UDP server to receive log messages, and a DatagramHandler
|
|
|
|
pointing to that server's address and port."""
|
|
|
|
BaseTest.setUp(self)
|
2017-01-09 12:54:12 -04:00
|
|
|
# Issue #29177: deal with errors that happen during setup
|
|
|
|
self.server = self.sock_hdlr = self.server_exception = None
|
|
|
|
try:
|
|
|
|
self.server = server = self.server_class(self.address,
|
|
|
|
self.handle_datagram, 0.01)
|
|
|
|
server.start()
|
|
|
|
# Uncomment next line to test error recovery in setUp()
|
|
|
|
# raise OSError('dummy error raised')
|
|
|
|
except OSError as e:
|
|
|
|
self.server_exception = e
|
|
|
|
return
|
2011-05-02 09:17:27 -03:00
|
|
|
server.ready.wait()
|
2013-09-27 14:18:28 -03:00
|
|
|
hcls = logging.handlers.DatagramHandler
|
|
|
|
if isinstance(server.server_address, tuple):
|
|
|
|
self.sock_hdlr = hcls('localhost', server.port)
|
|
|
|
else:
|
|
|
|
self.sock_hdlr = hcls(server.server_address, None)
|
2011-05-02 09:17:27 -03:00
|
|
|
self.log_output = ''
|
|
|
|
self.root_logger.removeHandler(self.root_logger.handlers[0])
|
|
|
|
self.root_logger.addHandler(self.sock_hdlr)
|
|
|
|
self.handled = threading.Event()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
"""Shutdown the UDP server."""
|
|
|
|
try:
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server:
|
2019-12-10 15:41:23 -04:00
|
|
|
self.server.stop()
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.sock_hdlr:
|
|
|
|
self.root_logger.removeHandler(self.sock_hdlr)
|
|
|
|
self.sock_hdlr.close()
|
2011-05-02 09:17:27 -03:00
|
|
|
finally:
|
|
|
|
BaseTest.tearDown(self)
|
|
|
|
|
|
|
|
def handle_datagram(self, request):
|
|
|
|
slen = struct.pack('>L', 0) # length of prefix
|
|
|
|
packet = request.packet[len(slen):]
|
|
|
|
obj = pickle.loads(packet)
|
|
|
|
record = logging.makeLogRecord(obj)
|
|
|
|
self.log_output += record.msg + '\n'
|
|
|
|
self.handled.set()
|
|
|
|
|
|
|
|
def test_output(self):
|
|
|
|
# The log message sent to the DatagramHandler is properly received.
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server_exception:
|
|
|
|
self.skipTest(self.server_exception)
|
2011-05-02 09:17:27 -03:00
|
|
|
logger = logging.getLogger("udp")
|
|
|
|
logger.error("spam")
|
|
|
|
self.handled.wait()
|
2011-05-02 10:43:00 -03:00
|
|
|
self.handled.clear()
|
|
|
|
logger.error("eggs")
|
|
|
|
self.handled.wait()
|
|
|
|
self.assertEqual(self.log_output, "spam\neggs\n")
|
2011-05-02 09:17:27 -03:00
|
|
|
|
2014-06-02 09:41:51 -03:00
|
|
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
2013-09-27 14:18:28 -03:00
|
|
|
class UnixDatagramHandlerTest(DatagramHandlerTest):
|
|
|
|
|
|
|
|
"""Test for DatagramHandler using Unix sockets."""
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
if hasattr(socket, "AF_UNIX"):
|
2013-09-27 15:08:24 -03:00
|
|
|
server_class = TestUnixDatagramServer
|
2013-09-27 14:18:28 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
# override the definition in the base class
|
2022-06-17 08:16:51 -03:00
|
|
|
self.address = socket_helper.create_unix_domain_name()
|
|
|
|
self.addCleanup(os_helper.unlink, self.address)
|
2013-09-27 14:18:28 -03:00
|
|
|
DatagramHandlerTest.setUp(self)
|
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2011-05-02 09:17:27 -03:00
|
|
|
class SysLogHandlerTest(BaseTest):
|
|
|
|
|
|
|
|
"""Test for SysLogHandler using UDP."""
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
server_class = TestUDPServer
|
|
|
|
address = ('localhost', 0)
|
2013-09-27 14:18:28 -03:00
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
def setUp(self):
|
|
|
|
"""Set up a UDP server to receive log messages, and a SysLogHandler
|
|
|
|
pointing to that server's address and port."""
|
|
|
|
BaseTest.setUp(self)
|
2017-01-09 12:54:12 -04:00
|
|
|
# Issue #29177: deal with errors that happen during setup
|
|
|
|
self.server = self.sl_hdlr = self.server_exception = None
|
|
|
|
try:
|
|
|
|
self.server = server = self.server_class(self.address,
|
|
|
|
self.handle_datagram, 0.01)
|
|
|
|
server.start()
|
|
|
|
# Uncomment next line to test error recovery in setUp()
|
|
|
|
# raise OSError('dummy error raised')
|
|
|
|
except OSError as e:
|
|
|
|
self.server_exception = e
|
|
|
|
return
|
2011-05-02 09:17:27 -03:00
|
|
|
server.ready.wait()
|
2013-09-27 14:18:28 -03:00
|
|
|
hcls = logging.handlers.SysLogHandler
|
|
|
|
if isinstance(server.server_address, tuple):
|
2017-06-01 10:11:56 -03:00
|
|
|
self.sl_hdlr = hcls((server.server_address[0], server.port))
|
2013-09-27 14:18:28 -03:00
|
|
|
else:
|
|
|
|
self.sl_hdlr = hcls(server.server_address)
|
2022-06-17 05:09:54 -03:00
|
|
|
self.log_output = b''
|
2011-05-02 09:17:27 -03:00
|
|
|
self.root_logger.removeHandler(self.root_logger.handlers[0])
|
|
|
|
self.root_logger.addHandler(self.sl_hdlr)
|
|
|
|
self.handled = threading.Event()
|
|
|
|
|
|
|
|
def tearDown(self):
|
2017-01-09 12:54:12 -04:00
|
|
|
"""Shutdown the server."""
|
2011-05-02 09:17:27 -03:00
|
|
|
try:
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server:
|
2019-12-10 15:41:23 -04:00
|
|
|
self.server.stop()
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.sl_hdlr:
|
|
|
|
self.root_logger.removeHandler(self.sl_hdlr)
|
|
|
|
self.sl_hdlr.close()
|
2011-05-02 09:17:27 -03:00
|
|
|
finally:
|
|
|
|
BaseTest.tearDown(self)
|
|
|
|
|
|
|
|
def handle_datagram(self, request):
|
|
|
|
self.log_output = request.packet
|
|
|
|
self.handled.set()
|
|
|
|
|
|
|
|
def test_output(self):
|
2017-01-09 12:54:12 -04:00
|
|
|
if self.server_exception:
|
|
|
|
self.skipTest(self.server_exception)
|
2011-05-02 09:17:27 -03:00
|
|
|
# The log message sent to the SysLogHandler is properly received.
|
|
|
|
logger = logging.getLogger("slh")
|
|
|
|
logger.error("sp\xe4m")
|
2023-07-25 10:13:59 -03:00
|
|
|
self.handled.wait(support.LONG_TIMEOUT)
|
2012-04-16 12:22:38 -03:00
|
|
|
self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m\x00')
|
2011-06-09 12:55:23 -03:00
|
|
|
self.handled.clear()
|
|
|
|
self.sl_hdlr.append_nul = False
|
|
|
|
logger.error("sp\xe4m")
|
2023-07-25 10:13:59 -03:00
|
|
|
self.handled.wait(support.LONG_TIMEOUT)
|
2012-04-16 12:22:38 -03:00
|
|
|
self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m')
|
2011-06-27 11:40:06 -03:00
|
|
|
self.handled.clear()
|
|
|
|
self.sl_hdlr.ident = "h\xe4m-"
|
|
|
|
logger.error("sp\xe4m")
|
2023-07-25 10:13:59 -03:00
|
|
|
self.handled.wait(support.LONG_TIMEOUT)
|
2012-04-16 12:22:38 -03:00
|
|
|
self.assertEqual(self.log_output, b'<11>h\xc3\xa4m-sp\xc3\xa4m')
|
2011-05-02 09:17:27 -03:00
|
|
|
|
2021-08-05 10:58:16 -03:00
|
|
|
def test_udp_reconnection(self):
|
|
|
|
logger = logging.getLogger("slh")
|
|
|
|
self.sl_hdlr.close()
|
|
|
|
self.handled.clear()
|
|
|
|
logger.error("sp\xe4m")
|
2023-07-25 10:13:59 -03:00
|
|
|
self.handled.wait(support.LONG_TIMEOUT)
|
2021-08-05 10:58:16 -03:00
|
|
|
self.assertEqual(self.log_output, b'<11>sp\xc3\xa4m\x00')
|
|
|
|
|
2014-06-02 09:41:51 -03:00
|
|
|
@unittest.skipUnless(hasattr(socket, "AF_UNIX"), "Unix sockets required")
|
2013-09-27 14:18:28 -03:00
|
|
|
class UnixSysLogHandlerTest(SysLogHandlerTest):
|
|
|
|
|
|
|
|
"""Test for SysLogHandler with Unix sockets."""
|
|
|
|
|
2017-09-07 13:56:24 -03:00
|
|
|
if hasattr(socket, "AF_UNIX"):
|
2013-09-27 15:08:24 -03:00
|
|
|
server_class = TestUnixDatagramServer
|
2013-09-27 14:18:28 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
# override the definition in the base class
|
2022-06-17 08:16:51 -03:00
|
|
|
self.address = socket_helper.create_unix_domain_name()
|
|
|
|
self.addCleanup(os_helper.unlink, self.address)
|
2013-09-27 14:18:28 -03:00
|
|
|
SysLogHandlerTest.setUp(self)
|
|
|
|
|
2020-04-25 04:06:29 -03:00
|
|
|
@unittest.skipUnless(socket_helper.IPV6_ENABLED,
|
2017-06-01 10:11:56 -03:00
|
|
|
'IPv6 support required for this test.')
|
|
|
|
class IPv6SysLogHandlerTest(SysLogHandlerTest):
|
|
|
|
|
|
|
|
"""Test for SysLogHandler with IPv6 host."""
|
|
|
|
|
|
|
|
server_class = TestUDPServer
|
|
|
|
address = ('::1', 0)
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
self.server_class.address_family = socket.AF_INET6
|
|
|
|
super(IPv6SysLogHandlerTest, self).setUp()
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.server_class.address_family = socket.AF_INET
|
|
|
|
super(IPv6SysLogHandlerTest, self).tearDown()
|
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2011-05-02 09:17:27 -03:00
|
|
|
class HTTPHandlerTest(BaseTest):
|
|
|
|
"""Test for HTTPHandler."""
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""Set up an HTTP server to receive log messages, and a HTTPHandler
|
|
|
|
pointing to that server's address and port."""
|
|
|
|
BaseTest.setUp(self)
|
|
|
|
self.handled = threading.Event()
|
|
|
|
|
|
|
|
def handle_request(self, request):
|
2011-05-05 08:59:14 -03:00
|
|
|
self.command = request.command
|
2011-05-02 09:17:27 -03:00
|
|
|
self.log_data = urlparse(request.path)
|
2011-05-05 08:59:14 -03:00
|
|
|
if self.command == 'POST':
|
|
|
|
try:
|
|
|
|
rlen = int(request.headers['Content-Length'])
|
|
|
|
self.post_data = request.rfile.read(rlen)
|
|
|
|
except:
|
|
|
|
self.post_data = None
|
2011-05-02 09:17:27 -03:00
|
|
|
request.send_response(200)
|
2011-05-10 05:10:08 -03:00
|
|
|
request.end_headers()
|
2011-05-02 09:17:27 -03:00
|
|
|
self.handled.set()
|
|
|
|
|
|
|
|
def test_output(self):
|
2011-05-09 18:05:50 -03:00
|
|
|
# The log message sent to the HTTPHandler is properly received.
|
2011-05-02 09:17:27 -03:00
|
|
|
logger = logging.getLogger("http")
|
2011-05-21 07:32:15 -03:00
|
|
|
root_logger = self.root_logger
|
|
|
|
root_logger.removeHandler(self.root_logger.handlers[0])
|
|
|
|
for secure in (False, True):
|
|
|
|
addr = ('localhost', 0)
|
|
|
|
if secure:
|
2011-05-21 12:46:41 -03:00
|
|
|
try:
|
|
|
|
import ssl
|
|
|
|
except ImportError:
|
|
|
|
sslctx = None
|
2014-11-03 15:29:33 -04:00
|
|
|
else:
|
|
|
|
here = os.path.dirname(__file__)
|
2023-09-16 13:47:18 -03:00
|
|
|
localhost_cert = os.path.join(here, "certdata", "keycert.pem")
|
2017-09-15 15:27:30 -03:00
|
|
|
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
2014-11-03 15:29:33 -04:00
|
|
|
sslctx.load_cert_chain(localhost_cert)
|
2014-11-23 22:36:44 -04:00
|
|
|
|
|
|
|
context = ssl.create_default_context(cafile=localhost_cert)
|
2011-05-05 08:59:14 -03:00
|
|
|
else:
|
2011-05-21 07:32:15 -03:00
|
|
|
sslctx = None
|
2014-11-23 22:36:44 -04:00
|
|
|
context = None
|
2011-05-21 07:32:15 -03:00
|
|
|
self.server = server = TestHTTPServer(addr, self.handle_request,
|
|
|
|
0.01, sslctx=sslctx)
|
|
|
|
server.start()
|
|
|
|
server.ready.wait()
|
|
|
|
host = 'localhost:%d' % server.server_port
|
2011-05-21 12:46:41 -03:00
|
|
|
secure_client = secure and sslctx
|
|
|
|
self.h_hdlr = logging.handlers.HTTPHandler(host, '/frob',
|
2014-11-23 22:36:44 -04:00
|
|
|
secure=secure_client,
|
2016-06-07 17:19:55 -03:00
|
|
|
context=context,
|
|
|
|
credentials=('foo', 'bar'))
|
2011-05-21 07:32:15 -03:00
|
|
|
self.log_data = None
|
|
|
|
root_logger.addHandler(self.h_hdlr)
|
|
|
|
|
|
|
|
for method in ('GET', 'POST'):
|
|
|
|
self.h_hdlr.method = method
|
|
|
|
self.handled.clear()
|
|
|
|
msg = "sp\xe4m"
|
|
|
|
logger.error(msg)
|
|
|
|
self.handled.wait()
|
|
|
|
self.assertEqual(self.log_data.path, '/frob')
|
|
|
|
self.assertEqual(self.command, method)
|
|
|
|
if method == 'GET':
|
|
|
|
d = parse_qs(self.log_data.query)
|
|
|
|
else:
|
|
|
|
d = parse_qs(self.post_data.decode('utf-8'))
|
|
|
|
self.assertEqual(d['name'], ['http'])
|
|
|
|
self.assertEqual(d['funcName'], ['test_output'])
|
|
|
|
self.assertEqual(d['msg'], [msg])
|
|
|
|
|
2019-12-10 15:41:23 -04:00
|
|
|
self.server.stop()
|
2011-05-21 07:32:15 -03:00
|
|
|
self.root_logger.removeHandler(self.h_hdlr)
|
|
|
|
self.h_hdlr.close()
|
2011-05-02 09:17:27 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
class MemoryTest(BaseTest):
|
|
|
|
|
|
|
|
"""Test memory persistence of logger objects."""
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
"""Create a dict to remember potentially destroyed objects."""
|
|
|
|
BaseTest.setUp(self)
|
|
|
|
self._survivors = {}
|
|
|
|
|
|
|
|
def _watch_for_survival(self, *args):
|
|
|
|
"""Watch the given objects for survival, by creating weakrefs to
|
|
|
|
them."""
|
|
|
|
for obj in args:
|
|
|
|
key = id(obj), repr(obj)
|
|
|
|
self._survivors[key] = weakref.ref(obj)
|
|
|
|
|
2009-06-30 20:06:06 -03:00
|
|
|
def _assertTruesurvival(self):
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
"""Assert that all objects watched for survival have survived."""
|
|
|
|
# Trigger cycle breaking.
|
|
|
|
gc.collect()
|
|
|
|
dead = []
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
for (id_, repr_), ref in self._survivors.items():
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
if ref() is None:
|
|
|
|
dead.append(repr_)
|
|
|
|
if dead:
|
|
|
|
self.fail("%d objects should have survived "
|
|
|
|
"but have been destroyed: %s" % (len(dead), ", ".join(dead)))
|
|
|
|
|
|
|
|
def test_persistent_loggers(self):
|
|
|
|
# Logger objects are persistent and retain their configuration, even
|
|
|
|
# if visible references are destroyed.
|
|
|
|
self.root_logger.setLevel(logging.INFO)
|
|
|
|
foo = logging.getLogger("foo")
|
|
|
|
self._watch_for_survival(foo)
|
|
|
|
foo.setLevel(logging.DEBUG)
|
|
|
|
self.root_logger.debug(self.next_message())
|
|
|
|
foo.debug(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('foo', 'DEBUG', '2'),
|
|
|
|
])
|
|
|
|
del foo
|
|
|
|
# foo has survived.
|
2009-06-30 20:06:06 -03:00
|
|
|
self._assertTruesurvival()
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# foo has retained its settings.
|
|
|
|
bar = logging.getLogger("foo")
|
|
|
|
bar.debug(self.next_message())
|
2009-06-30 21:43:10 -03:00
|
|
|
self.assert_log_lines([
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
('foo', 'DEBUG', '2'),
|
|
|
|
('foo', 'DEBUG', '3'),
|
|
|
|
])
|
|
|
|
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
class EncodingTest(BaseTest):
|
|
|
|
def test_encoding_plain_file(self):
|
|
|
|
# In Python 2.x, a plain file object is treated as having no encoding.
|
|
|
|
log = logging.getLogger("test")
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file(".log", "test_logging-1-")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
# the non-ascii data we write to the log.
|
|
|
|
data = "foo\x80"
|
|
|
|
try:
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
handler = logging.FileHandler(fn, encoding="utf-8")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
log.addHandler(handler)
|
|
|
|
try:
|
|
|
|
# write non-ascii data to the log.
|
|
|
|
log.warning(data)
|
|
|
|
finally:
|
|
|
|
log.removeHandler(handler)
|
|
|
|
handler.close()
|
|
|
|
# check we wrote exactly those bytes, ignoring trailing \n etc
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
f = open(fn, encoding="utf-8")
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
try:
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertEqual(f.read().rstrip(), data)
|
Merged revisions 66141,66145,66150,66180,66211,66217,66219,66226,66231,66244,66246,66249-66250,66264,66268,66272,66294,66306 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r66141 | gregory.p.smith | 2008-09-02 00:29:51 -0500 (Tue, 02 Sep 2008) | 3 lines
Issue #3678: Correctly pass LDFLAGS and LDLAST to the linker on shared
library targets in the Makefile.
........
r66145 | marc-andre.lemburg | 2008-09-02 05:32:34 -0500 (Tue, 02 Sep 2008) | 5 lines
Add quotes around the file name to avoid issues with spaces.
Closes #3719.
........
r66150 | marc-andre.lemburg | 2008-09-02 07:11:19 -0500 (Tue, 02 Sep 2008) | 3 lines
Add news item for #3719.
........
r66180 | vinay.sajip | 2008-09-03 04:20:05 -0500 (Wed, 03 Sep 2008) | 1 line
Issue #3726: Allowed spaces in separators in logging configuration files.
........
r66211 | vinay.sajip | 2008-09-04 02:31:21 -0500 (Thu, 04 Sep 2008) | 1 line
Issue #3772: Fixed regression problem in StreamHandler.emit().
........
r66217 | andrew.kuchling | 2008-09-04 08:26:24 -0500 (Thu, 04 Sep 2008) | 1 line
#3671: various corrections and markup fixes noted by Kent Johnson
........
r66219 | hirokazu.yamamoto | 2008-09-04 09:25:30 -0500 (Thu, 04 Sep 2008) | 1 line
Added NEWS
........
r66226 | benjamin.peterson | 2008-09-04 18:31:27 -0500 (Thu, 04 Sep 2008) | 1 line
flesh out the documentation on using 2to3
........
r66231 | andrew.kuchling | 2008-09-05 10:15:56 -0500 (Fri, 05 Sep 2008) | 1 line
#3671: Typo fix
........
r66244 | jesse.noller | 2008-09-05 20:20:11 -0500 (Fri, 05 Sep 2008) | 2 lines
Fix typo in multiprocessing doc, cancel_join_thread was missing _thread
........
r66246 | benjamin.peterson | 2008-09-05 22:00:00 -0500 (Fri, 05 Sep 2008) | 1 line
actually tell the name of the flag to use
........
r66249 | andrew.kuchling | 2008-09-06 07:50:05 -0500 (Sat, 06 Sep 2008) | 1 line
Various corrections
........
r66250 | andrew.kuchling | 2008-09-06 08:04:02 -0500 (Sat, 06 Sep 2008) | 1 line
#3040: include 'dest' argument in example; trim some trailing whitespace
........
r66264 | benjamin.peterson | 2008-09-06 14:42:39 -0500 (Sat, 06 Sep 2008) | 1 line
docs are pretty good about new-style classes these days
........
r66268 | andrew.kuchling | 2008-09-06 15:28:01 -0500 (Sat, 06 Sep 2008) | 1 line
#3669 from Robert Lehmann: simplify use of iterator in example
........
r66272 | andrew.kuchling | 2008-09-06 16:26:02 -0500 (Sat, 06 Sep 2008) | 1 line
#1317: describe the does_esmtp, ehlo_resp, esmtp_features, and helo_resp attributes
........
r66294 | georg.brandl | 2008-09-07 12:00:17 -0500 (Sun, 07 Sep 2008) | 2 lines
Add a new howto about Python and the web, by Marek Kubica.
........
r66306 | mark.summerfield | 2008-09-08 09:45:37 -0500 (Mon, 08 Sep 2008) | 3 lines
Added xrefs to each other.
........
2008-09-08 20:05:23 -03:00
|
|
|
finally:
|
|
|
|
f.close()
|
|
|
|
finally:
|
|
|
|
if os.path.isfile(fn):
|
|
|
|
os.remove(fn)
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
def test_encoding_cyrillic_unicode(self):
|
|
|
|
log = logging.getLogger("test")
|
2017-12-14 07:04:53 -04:00
|
|
|
# Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye)
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
message = '\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
|
2017-12-14 07:04:53 -04:00
|
|
|
# Ensure it's written in a Cyrillic encoding
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
writer_class = codecs.getwriter('cp1251')
|
Merged revisions 70768,71657,71721,71729,71794,71976,72036-72037,72079,72085,72131-72134,72191,72197-72198,72219,72221,72225,72303,72434,72467,72476 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70768 | andrew.kuchling | 2009-03-30 17:29:15 -0500 (Mon, 30 Mar 2009) | 1 line
Typo fixes
........
r71657 | vinay.sajip | 2009-04-16 14:07:37 -0500 (Thu, 16 Apr 2009) | 1 line
Issue #5768: Change to Unicode output logic and test case for same.
........
r71721 | benjamin.peterson | 2009-04-18 14:26:19 -0500 (Sat, 18 Apr 2009) | 1 line
fix a few nits in unittest.py #5771
........
r71729 | benjamin.peterson | 2009-04-18 16:03:10 -0500 (Sat, 18 Apr 2009) | 1 line
move test to a more appropiate one
........
r71794 | vinay.sajip | 2009-04-22 07:10:47 -0500 (Wed, 22 Apr 2009) | 2 lines
Issue #5170: Fixed regression caused when fixing #5768.
........
r71976 | mark.dickinson | 2009-04-26 14:54:55 -0500 (Sun, 26 Apr 2009) | 2 lines
Fix typo in function name
........
r72036 | georg.brandl | 2009-04-27 12:04:23 -0500 (Mon, 27 Apr 2009) | 1 line
#5848: small unittest doc patch.
........
r72037 | georg.brandl | 2009-04-27 12:09:53 -0500 (Mon, 27 Apr 2009) | 1 line
#5840: dont claim we dont support TLS.
........
r72079 | r.david.murray | 2009-04-28 14:02:55 -0500 (Tue, 28 Apr 2009) | 2 lines
Remove spurious 'u'.
........
r72085 | georg.brandl | 2009-04-28 16:48:35 -0500 (Tue, 28 Apr 2009) | 1 line
Make the doctests in the docs pass, except for those in the turtle module.
........
r72131 | benjamin.peterson | 2009-04-29 17:43:35 -0500 (Wed, 29 Apr 2009) | 1 line
fix test_shutil on ZFS #5676
........
r72132 | georg.brandl | 2009-04-29 17:44:07 -0500 (Wed, 29 Apr 2009) | 1 line
#5878: fix repr of re object.
........
r72133 | benjamin.peterson | 2009-04-29 17:44:15 -0500 (Wed, 29 Apr 2009) | 1 line
make sure mode is removable while cleaning up test droppings
........
r72134 | benjamin.peterson | 2009-04-29 19:06:33 -0500 (Wed, 29 Apr 2009) | 1 line
make sure to close file
........
r72191 | michael.foord | 2009-05-02 06:43:06 -0500 (Sat, 02 May 2009) | 9 lines
Adds an exit parameter to unittest.main(). If False main no longer
calls sys.exit.
Closes issue 3379.
Michael Foord
........
r72197 | benjamin.peterson | 2009-05-02 11:24:37 -0500 (Sat, 02 May 2009) | 1 line
don't let sys.argv be used in the tests
........
r72198 | andrew.kuchling | 2009-05-02 12:12:15 -0500 (Sat, 02 May 2009) | 1 line
Add items
........
r72219 | michael.foord | 2009-05-02 15:15:05 -0500 (Sat, 02 May 2009) | 8 lines
Add addCleanup and doCleanups to unittest.TestCase.
Closes issue 5679.
Michael Foord
........
r72221 | benjamin.peterson | 2009-05-02 15:26:53 -0500 (Sat, 02 May 2009) | 1 line
add myself
........
r72225 | michael.foord | 2009-05-02 17:43:34 -0500 (Sat, 02 May 2009) | 1 line
........
r72303 | benjamin.peterson | 2009-05-04 19:55:24 -0500 (Mon, 04 May 2009) | 1 line
using sys._getframe(x), where x > 0 doesnt' work on IronPython
........
r72434 | r.david.murray | 2009-05-07 13:09:58 -0500 (Thu, 07 May 2009) | 2 lines
Pre-opened test file needs to be opened in binary mode.
........
r72467 | georg.brandl | 2009-05-08 07:17:34 -0500 (Fri, 08 May 2009) | 1 line
Fix name.
........
r72476 | thomas.heller | 2009-05-08 15:09:40 -0500 (Fri, 08 May 2009) | 4 lines
Add a file that contains diffs between offical libffi files and the
files in this repository. Should make it easier to merge new libffi
versions.
........
2009-05-08 17:42:26 -03:00
|
|
|
writer_class.encoding = 'cp1251'
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
stream = io.BytesIO()
|
|
|
|
writer = writer_class(stream, 'strict')
|
|
|
|
handler = logging.StreamHandler(writer)
|
|
|
|
log.addHandler(handler)
|
|
|
|
try:
|
|
|
|
log.warning(message)
|
|
|
|
finally:
|
|
|
|
log.removeHandler(handler)
|
|
|
|
handler.close()
|
|
|
|
# check we wrote exactly those bytes, ignoring trailing \n etc
|
|
|
|
s = stream.getvalue()
|
2017-12-14 07:04:53 -04:00
|
|
|
# Compare against what the data should be when encoded in CP-1251
|
Merged revisions 69364-69365,69409-69410,69413,69417,69435,69442,69447,69495,69519-69521 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69364 | kristjan.jonsson | 2009-02-06 04:17:34 -0600 (Fri, 06 Feb 2009) | 1 line
Fix a number of Win32ErrorTests error cases. chmod wasn't being tested. 'access' never raises an error.
........
r69365 | armin.rigo | 2009-02-06 05:46:26 -0600 (Fri, 06 Feb 2009) | 2 lines
Ivan on IRC in #twisted reported this crasher.
........
r69409 | georg.brandl | 2009-02-07 06:21:17 -0600 (Sat, 07 Feb 2009) | 1 line
#5174: fix wrong file closing in example.
........
r69410 | neil.schemenauer | 2009-02-07 08:53:31 -0600 (Sat, 07 Feb 2009) | 4 lines
Fix broken test in test_hotshot. Treating the current directory as an
empty file is sloppy and non-portable. Use NamedTemporaryFile to make
an empty file.
........
r69413 | neil.schemenauer | 2009-02-07 12:35:16 -0600 (Sat, 07 Feb 2009) | 2 lines
Add test for issue #999042, explict global statement works.
........
r69417 | benjamin.peterson | 2009-02-07 17:01:19 -0600 (Sat, 07 Feb 2009) | 1 line
document individual 2to3 fixers
........
r69435 | benjamin.peterson | 2009-02-08 08:38:13 -0600 (Sun, 08 Feb 2009) | 1 line
document numliterals fixer
........
r69442 | benjamin.peterson | 2009-02-08 09:14:57 -0600 (Sun, 08 Feb 2009) | 1 line
a few edits and typos
........
r69447 | vinay.sajip | 2009-02-08 13:06:08 -0600 (Sun, 08 Feb 2009) | 2 lines
Issue #5170: Fixed Unicode output bug in logging and added test case. This is a regression which did not occur in 2.5.
........
r69495 | kristjan.jonsson | 2009-02-10 07:32:24 -0600 (Tue, 10 Feb 2009) | 1 line
Issue 4804. Add a function to test the validity of file descriptors on Windows, and stop using global runtime settings to silence the warnings / assertions.
........
r69519 | gregory.p.smith | 2009-02-11 17:45:25 -0600 (Wed, 11 Feb 2009) | 3 lines
Issue #1008086: Fixes socket.inet_aton() to always return 4 bytes even
on LP64 platforms (most 64-bit Linux, bsd, unix systems).
........
r69520 | benjamin.peterson | 2009-02-11 21:50:00 -0600 (Wed, 11 Feb 2009) | 1 line
os.fsync() should be used to ensure that data is written to disk
........
r69521 | benjamin.peterson | 2009-02-11 22:17:04 -0600 (Wed, 11 Feb 2009) | 1 line
no need for this __bases__ trick anymore
........
2009-02-12 22:50:59 -04:00
|
|
|
self.assertEqual(s, b'\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
|
|
|
|
|
|
|
|
|
2008-12-07 11:30:06 -04:00
|
|
|
class WarningsTest(BaseTest):
|
2009-04-01 17:01:47 -03:00
|
|
|
|
2008-12-07 11:30:06 -04:00
|
|
|
def test_warnings(self):
|
2009-04-01 17:01:47 -03:00
|
|
|
with warnings.catch_warnings():
|
2009-04-05 15:57:32 -03:00
|
|
|
logging.captureWarnings(True)
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(logging.captureWarnings, False)
|
2011-03-29 13:20:34 -03:00
|
|
|
warnings.filterwarnings("always", category=UserWarning)
|
|
|
|
stream = io.StringIO()
|
|
|
|
h = logging.StreamHandler(stream)
|
|
|
|
logger = logging.getLogger("py.warnings")
|
|
|
|
logger.addHandler(h)
|
|
|
|
warnings.warn("I'm warning you...")
|
|
|
|
logger.removeHandler(h)
|
|
|
|
s = stream.getvalue()
|
|
|
|
h.close()
|
2012-10-17 08:24:27 -03:00
|
|
|
self.assertGreater(s.find("UserWarning: I'm warning you...\n"), 0)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# See if an explicit file uses the original implementation
|
2011-03-29 13:20:34 -03:00
|
|
|
a_file = io.StringIO()
|
|
|
|
warnings.showwarning("Explicit", UserWarning, "dummy.py", 42,
|
|
|
|
a_file, "Dummy line")
|
|
|
|
s = a_file.getvalue()
|
|
|
|
a_file.close()
|
|
|
|
self.assertEqual(s,
|
|
|
|
"dummy.py:42: UserWarning: Explicit\n Dummy line\n")
|
|
|
|
|
|
|
|
def test_warnings_no_handlers(self):
|
|
|
|
with warnings.catch_warnings():
|
|
|
|
logging.captureWarnings(True)
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(logging.captureWarnings, False)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
# confirm our assumption: no loggers are set
|
|
|
|
logger = logging.getLogger("py.warnings")
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertEqual(logger.handlers, [])
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
warnings.showwarning("Explicit", UserWarning, "dummy.py", 42)
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertEqual(len(logger.handlers), 1)
|
2011-03-29 13:20:34 -03:00
|
|
|
self.assertIsInstance(logger.handlers[0], logging.NullHandler)
|
2008-12-07 11:30:06 -04:00
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
def formatFunc(format, datefmt=None):
|
|
|
|
return logging.Formatter(format, datefmt)
|
|
|
|
|
2018-10-15 15:41:36 -03:00
|
|
|
class myCustomFormatter:
|
|
|
|
def __init__(self, fmt, datefmt=None):
|
|
|
|
pass
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def handlerFunc():
|
|
|
|
return logging.StreamHandler()
|
|
|
|
|
|
|
|
class CustomHandler(logging.StreamHandler):
|
|
|
|
pass
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
class CustomListener(logging.handlers.QueueListener):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class CustomQueue(queue.Queue):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def queueMaker():
|
|
|
|
return queue.Queue()
|
|
|
|
|
|
|
|
def listenerMaker(arg1, arg2, respect_handler_level=False):
|
|
|
|
def func(queue, *handlers, **kwargs):
|
|
|
|
kwargs.setdefault('respect_handler_level', respect_handler_level)
|
|
|
|
return CustomListener(queue, *handlers, **kwargs)
|
|
|
|
return func
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
class ConfigDictTest(BaseTest):
|
|
|
|
|
|
|
|
"""Reading logging config from a dictionary."""
|
|
|
|
|
2020-06-30 10:46:06 -03:00
|
|
|
check_no_resource_warning = warnings_helper.check_no_resource_warning
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^(\w+) \+\+ (\w+)$"
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
# config0 is a standard configuration.
|
|
|
|
config0 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# config1 adds a little to the standard configuration.
|
|
|
|
config1 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2011-03-07 14:02:57 -04:00
|
|
|
# config1a moves the handler to the root. Used with config8a
|
|
|
|
config1a = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
# config2 has a subtle configuration error that should be reported
|
|
|
|
config2 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdbout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config1 but with a misspelt level on a handler
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config2a = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NTOSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config1 but with a misspelt level on a logger
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config2b = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WRANING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# config3 has a less subtle configuration error
|
|
|
|
config3 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'misspelled_name',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# config4 specifies a custom formatter class to be loaded
|
|
|
|
config4 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'()' : __name__ + '.ExceptionFormatter',
|
|
|
|
'format' : '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# As config4 but using an actual callable rather than a string
|
|
|
|
config4a = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'()' : ExceptionFormatter,
|
|
|
|
'format' : '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
},
|
|
|
|
'form2' : {
|
|
|
|
'()' : __name__ + '.formatFunc',
|
|
|
|
'format' : '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
},
|
|
|
|
'form3' : {
|
|
|
|
'()' : formatFunc,
|
|
|
|
'format' : '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
'hand2' : {
|
|
|
|
'()' : handlerFunc,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# config5 specifies a custom handler class to be loaded
|
|
|
|
config5 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : __name__ + '.CustomHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
# config6 specifies a custom handler class to be loaded
|
|
|
|
# but has bad arguments
|
|
|
|
config6 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : __name__ + '.CustomHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
'9' : 'invalid parameter name',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# config 7 does not define compiler.parser but defines compiler.lexer
|
|
|
|
# so compiler.parser should be disabled after applying it
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config7 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.lexer' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2011-03-07 14:02:57 -04:00
|
|
|
# config8 defines both compiler and compiler.lexer
|
|
|
|
# so compiler.parser should not be disabled (since
|
|
|
|
# compiler is defined)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config8 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'disable_existing_loggers' : False,
|
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
'compiler.lexer' : {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2011-03-07 14:02:57 -04:00
|
|
|
# config8a disables existing loggers
|
|
|
|
config8a = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers' : True,
|
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
'compiler.lexer' : {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config9 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config9a = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'incremental' : True,
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'INFO',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
config9b = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'incremental' : True,
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'level' : 'INFO',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'INFO',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config1 but with a filter added
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config10 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'filters' : {
|
|
|
|
'filt1' : {
|
|
|
|
'name' : 'compiler.parser',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
'filters' : ['filt1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'filters' : ['filt1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config1 but using cfg:// references
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
config11 = {
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
'version': 1,
|
|
|
|
'true_formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handler_configs': {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'formatters' : 'cfg://true_formatters',
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : 'cfg://handler_configs[hand1]',
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config11 but missing the version key
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
config12 = {
|
|
|
|
'true_formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handler_configs': {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'formatters' : 'cfg://true_formatters',
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : 'cfg://handler_configs[hand1]',
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# As config11 but using an unsupported version
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
config13 = {
|
|
|
|
'version': 2,
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
'true_formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handler_configs': {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'formatters' : 'cfg://true_formatters',
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : 'cfg://handler_configs[hand1]',
|
|
|
|
},
|
|
|
|
'loggers' : {
|
|
|
|
'compiler.parser' : {
|
|
|
|
'level' : 'DEBUG',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2012-11-15 10:20:18 -04:00
|
|
|
# As config0, but with properties
|
|
|
|
config14 = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(levelname)s ++ %(message)s',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
'.': {
|
|
|
|
'foo': 'bar',
|
|
|
|
'terminator': '!\n',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
# config0 but with default values for formatter. Skipped 15, it is defined
|
|
|
|
# in the test code.
|
|
|
|
config16 = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1' : {
|
|
|
|
'format' : '%(message)s ++ %(customfield)s',
|
|
|
|
'defaults': {"customfield": "defaultvalue"}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'form1',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-11-09 14:55:22 -04:00
|
|
|
class CustomFormatter(logging.Formatter):
|
|
|
|
custom_property = "."
|
|
|
|
|
|
|
|
def format(self, record):
|
|
|
|
return super().format(record)
|
|
|
|
|
|
|
|
config17 = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
"custom": {
|
|
|
|
"()": CustomFormatter,
|
|
|
|
"style": "{",
|
|
|
|
"datefmt": "%Y-%m-%d %H:%M:%S",
|
|
|
|
"format": "{message}", # <-- to force an exception when configuring
|
|
|
|
".": {
|
|
|
|
"custom_property": "value"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class' : 'logging.StreamHandler',
|
|
|
|
'formatter' : 'custom',
|
|
|
|
'level' : 'NOTSET',
|
|
|
|
'stream' : 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root' : {
|
|
|
|
'level' : 'WARNING',
|
|
|
|
'handlers' : ['hand1'],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
bad_format = {
|
2013-03-22 12:19:54 -03:00
|
|
|
"version": 1,
|
|
|
|
"formatters": {
|
|
|
|
"mySimpleFormatter": {
|
2013-03-29 14:56:54 -03:00
|
|
|
"format": "%(asctime)s (%(name)s) %(levelname)s: %(message)s",
|
|
|
|
"style": "$"
|
2013-03-22 12:19:54 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"handlers": {
|
|
|
|
"fileGlobal": {
|
|
|
|
"class": "logging.StreamHandler",
|
|
|
|
"level": "DEBUG",
|
|
|
|
"formatter": "mySimpleFormatter"
|
|
|
|
},
|
|
|
|
"bufferGlobal": {
|
|
|
|
"class": "logging.handlers.MemoryHandler",
|
|
|
|
"capacity": 5,
|
|
|
|
"formatter": "mySimpleFormatter",
|
|
|
|
"target": "fileGlobal",
|
|
|
|
"level": "DEBUG"
|
2022-06-07 05:20:35 -03:00
|
|
|
}
|
2013-03-22 12:19:54 -03:00
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"mymodule": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["bufferGlobal"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-15 15:41:36 -03:00
|
|
|
# Configuration with custom logging.Formatter subclass as '()' key and 'validate' set to False
|
|
|
|
custom_formatter_class_validate = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1': {
|
|
|
|
'()': __name__ + '.ExceptionFormatter',
|
|
|
|
'format': '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
'validate': False,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'form1',
|
|
|
|
'level': 'NOTSET',
|
|
|
|
'stream': 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"my_test_logger_custom_formatter": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["hand1"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Configuration with custom logging.Formatter subclass as 'class' key and 'validate' set to False
|
|
|
|
custom_formatter_class_validate2 = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1': {
|
|
|
|
'class': __name__ + '.ExceptionFormatter',
|
|
|
|
'format': '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
'validate': False,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'form1',
|
|
|
|
'level': 'NOTSET',
|
|
|
|
'stream': 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"my_test_logger_custom_formatter": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["hand1"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Configuration with custom class that is not inherited from logging.Formatter
|
|
|
|
custom_formatter_class_validate3 = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1': {
|
|
|
|
'class': __name__ + '.myCustomFormatter',
|
|
|
|
'format': '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
'validate': False,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'form1',
|
|
|
|
'level': 'NOTSET',
|
|
|
|
'stream': 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"my_test_logger_custom_formatter": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["hand1"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
# Configuration with custom function, 'validate' set to False and no defaults
|
2018-10-15 15:41:36 -03:00
|
|
|
custom_formatter_with_function = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1': {
|
|
|
|
'()': formatFunc,
|
|
|
|
'format': '%(levelname)s:%(name)s:%(message)s',
|
|
|
|
'validate': False,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'form1',
|
|
|
|
'level': 'NOTSET',
|
|
|
|
'stream': 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"my_test_logger_custom_formatter": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["hand1"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
# Configuration with custom function, and defaults
|
|
|
|
custom_formatter_with_defaults = {
|
|
|
|
'version': 1,
|
|
|
|
'formatters': {
|
|
|
|
'form1': {
|
|
|
|
'()': formatFunc,
|
|
|
|
'format': '%(levelname)s:%(name)s:%(message)s:%(customfield)s',
|
|
|
|
'defaults': {"customfield": "myvalue"}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'handlers' : {
|
|
|
|
'hand1' : {
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
'formatter': 'form1',
|
|
|
|
'level': 'NOTSET',
|
|
|
|
'stream': 'ext://sys.stdout',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"loggers": {
|
|
|
|
"my_test_logger_custom_formatter": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["hand1"],
|
|
|
|
"propagate": "true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
config_queue_handler = {
|
|
|
|
'version': 1,
|
|
|
|
'handlers' : {
|
|
|
|
'h1' : {
|
|
|
|
'class': 'logging.FileHandler',
|
|
|
|
},
|
|
|
|
# key is before depended on handlers to test that deferred config works
|
|
|
|
'ah' : {
|
|
|
|
'class': 'logging.handlers.QueueHandler',
|
|
|
|
'handlers': ['h1']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"root": {
|
|
|
|
"level": "DEBUG",
|
|
|
|
"handlers": ["ah"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def apply_config(self, conf):
|
|
|
|
logging.config.dictConfig(conf)
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
def check_handler(self, name, cls):
|
|
|
|
h = logging.getHandlerByName(name)
|
|
|
|
self.assertIsInstance(h, cls)
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def test_config0_ok(self):
|
|
|
|
# A simple config which overrides the default settings.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config0)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger()
|
|
|
|
# Won't output anything
|
|
|
|
logger.info(self.next_message())
|
|
|
|
# Outputs a message
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
|
|
|
def test_config1_ok(self, config=config1):
|
|
|
|
# A config defining a sub-parser as well.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(config)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
|
|
|
def test_config2_failure(self):
|
|
|
|
# A simple config which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config2)
|
|
|
|
|
|
|
|
def test_config2a_failure(self):
|
|
|
|
# A simple config which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config2a)
|
|
|
|
|
|
|
|
def test_config2b_failure(self):
|
|
|
|
# A simple config which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config2b)
|
|
|
|
|
|
|
|
def test_config3_failure(self):
|
|
|
|
# A simple config which overrides the default settings.
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config3)
|
|
|
|
|
|
|
|
def test_config4_ok(self):
|
|
|
|
# A config specifying a custom formatter class.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config4)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
#logger = logging.getLogger()
|
|
|
|
try:
|
|
|
|
raise RuntimeError()
|
|
|
|
except RuntimeError:
|
|
|
|
logging.exception("just testing")
|
|
|
|
sys.stdout.seek(0)
|
2010-11-20 15:04:17 -04:00
|
|
|
self.assertEqual(output.getvalue(),
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
"ERROR:root:just testing\nGot a [RuntimeError]\n")
|
|
|
|
# Original logger output is empty
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
|
|
|
def test_config4a_ok(self):
|
|
|
|
# A config specifying a custom formatter class.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config4a)
|
|
|
|
#logger = logging.getLogger()
|
|
|
|
try:
|
|
|
|
raise RuntimeError()
|
|
|
|
except RuntimeError:
|
|
|
|
logging.exception("just testing")
|
|
|
|
sys.stdout.seek(0)
|
2010-11-20 15:04:17 -04:00
|
|
|
self.assertEqual(output.getvalue(),
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
"ERROR:root:just testing\nGot a [RuntimeError]\n")
|
|
|
|
# Original logger output is empty
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
|
|
|
def test_config5_ok(self):
|
|
|
|
self.test_config1_ok(config=self.config5)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', CustomHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
|
|
|
def test_config6_failure(self):
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config6)
|
|
|
|
|
|
|
|
def test_config7_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config1)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config7)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
self.assertTrue(logger.disabled)
|
|
|
|
logger = logging.getLogger("compiler.lexer")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '3'),
|
|
|
|
('ERROR', '4'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
2017-12-14 07:04:53 -04:00
|
|
|
# Same as test_config_7_ok but don't disable old loggers.
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def test_config_8_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config1)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
2011-03-07 14:02:57 -04:00
|
|
|
# All will output a message
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config8)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
logger = logging.getLogger("compiler.lexer")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '3'),
|
|
|
|
('ERROR', '4'),
|
|
|
|
('INFO', '5'),
|
|
|
|
('ERROR', '6'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
2011-03-07 14:02:57 -04:00
|
|
|
def test_config_8a_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2011-03-07 14:02:57 -04:00
|
|
|
self.apply_config(self.config1a)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
2011-03-07 14:02:57 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# See issue #11424. compiler-hyphenated sorts
|
|
|
|
# between compiler and compiler.xyz and this
|
|
|
|
# was preventing compiler.xyz from being included
|
|
|
|
# in the child loggers of compiler because of an
|
|
|
|
# overzealous loop termination condition.
|
|
|
|
hyphenated = logging.getLogger('compiler-hyphenated')
|
|
|
|
# All will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
hyphenated.critical(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
('CRITICAL', '3'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2011-03-07 14:02:57 -04:00
|
|
|
self.apply_config(self.config8a)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
2011-03-07 14:02:57 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
logger = logging.getLogger("compiler.lexer")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
# Will not appear
|
|
|
|
hyphenated.critical(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '4'),
|
|
|
|
('ERROR', '5'),
|
|
|
|
('INFO', '6'),
|
|
|
|
('ERROR', '7'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def test_config_9_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config9)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
2017-12-14 07:04:53 -04:00
|
|
|
# Nothing will be output since both handler and logger are set to WARNING
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.info(self.next_message())
|
|
|
|
self.assert_log_lines([], stream=output)
|
|
|
|
self.apply_config(self.config9a)
|
2017-12-14 07:04:53 -04:00
|
|
|
# Nothing will be output since handler is still set to WARNING
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.info(self.next_message())
|
|
|
|
self.assert_log_lines([], stream=output)
|
|
|
|
self.apply_config(self.config9b)
|
2017-12-14 07:04:53 -04:00
|
|
|
# Message should now be output
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.info(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '3'),
|
|
|
|
], stream=output)
|
|
|
|
|
|
|
|
def test_config_10_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.apply_config(self.config10)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger('compiler')
|
2017-12-14 07:04:53 -04:00
|
|
|
# Not output, because filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger('compiler.lexer')
|
2017-12-14 07:04:53 -04:00
|
|
|
# Not output, because filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger("compiler.parser.codegen")
|
2017-12-14 07:04:53 -04:00
|
|
|
# Output, as not filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('WARNING', '1'),
|
|
|
|
('ERROR', '4'),
|
|
|
|
], stream=output)
|
|
|
|
|
|
|
|
def test_config11_ok(self):
|
|
|
|
self.test_config1_ok(self.config11)
|
|
|
|
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
def test_config12_failure(self):
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config12)
|
|
|
|
|
|
|
|
def test_config13_failure(self):
|
|
|
|
self.assertRaises(Exception, self.apply_config, self.config13)
|
|
|
|
|
2012-11-15 10:20:18 -04:00
|
|
|
def test_config14_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2012-11-15 10:20:18 -04:00
|
|
|
self.apply_config(self.config14)
|
|
|
|
h = logging._handlers['hand1']
|
|
|
|
self.assertEqual(h.foo, 'bar')
|
|
|
|
self.assertEqual(h.terminator, '!\n')
|
|
|
|
logging.warning('Exclamation')
|
|
|
|
self.assertTrue(output.getvalue().endswith('Exclamation!\n'))
|
|
|
|
|
2018-07-02 05:57:46 -03:00
|
|
|
def test_config15_ok(self):
|
|
|
|
|
|
|
|
with self.check_no_resource_warning():
|
2022-05-26 13:11:15 -03:00
|
|
|
fn = make_temp_file(".log", "test_logging-X-")
|
2018-07-02 05:57:46 -03:00
|
|
|
|
|
|
|
config = {
|
|
|
|
"version": 1,
|
|
|
|
"handlers": {
|
|
|
|
"file": {
|
|
|
|
"class": "logging.FileHandler",
|
2021-04-28 23:34:56 -03:00
|
|
|
"filename": fn,
|
|
|
|
"encoding": "utf-8",
|
2018-07-02 05:57:46 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"root": {
|
|
|
|
"handlers": ["file"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
self.apply_config(config)
|
|
|
|
self.apply_config(config)
|
|
|
|
|
|
|
|
handler = logging.root.handlers[0]
|
2022-06-07 05:20:35 -03:00
|
|
|
self.addCleanup(closeFileHandler, handler, fn)
|
2018-07-02 05:57:46 -03:00
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
def test_config16_ok(self):
|
|
|
|
self.apply_config(self.config16)
|
|
|
|
h = logging._handlers['hand1']
|
|
|
|
|
|
|
|
# Custom value
|
|
|
|
result = h.formatter.format(logging.makeLogRecord(
|
|
|
|
{'msg': 'Hello', 'customfield': 'customvalue'}))
|
|
|
|
self.assertEqual(result, 'Hello ++ customvalue')
|
|
|
|
|
|
|
|
# Default value
|
|
|
|
result = h.formatter.format(logging.makeLogRecord(
|
|
|
|
{'msg': 'Hello'}))
|
|
|
|
self.assertEqual(result, 'Hello ++ defaultvalue')
|
|
|
|
|
2023-11-09 14:55:22 -04:00
|
|
|
def test_config17_ok(self):
|
|
|
|
self.apply_config(self.config17)
|
|
|
|
h = logging._handlers['hand1']
|
|
|
|
self.assertEqual(h.formatter.custom_property, 'value')
|
2023-04-12 04:35:56 -03:00
|
|
|
|
2012-10-02 11:56:16 -03:00
|
|
|
def setup_via_listener(self, text, verify=None):
|
Merged revisions 77967,77969,77973,77979,77985-77986,78009,78029,78031-78033,78081,78085,78103,78105-78106,78108,78246,78703,78728,78731,78853,78855 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 12:48:53 -0600 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 14:18:28 -0600 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r77973 | vinay.sajip | 2010-02-04 14:23:45 -0600 (Thu, 04 Feb 2010) | 1 line
Issue #7851: logging: clarification on logging configuration files.
........
r77979 | vinay.sajip | 2010-02-04 15:40:56 -0600 (Thu, 04 Feb 2010) | 1 line
Added unit test for cfg:// resolution.
........
r77985 | vinay.sajip | 2010-02-05 08:52:05 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener test now uses find_unused_port().
........
r77986 | vinay.sajip | 2010-02-05 09:40:20 -0600 (Fri, 05 Feb 2010) | 1 line
Issue #7857: test_logging: listener tests disabled for now.
........
r78009 | vinay.sajip | 2010-02-05 17:43:11 -0600 (Fri, 05 Feb 2010) | 1 line
test_logging: minor tweaks to timeouts, listening tests marked as skipped.
........
r78029 | vinay.sajip | 2010-02-06 14:00:43 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Tentatively re-enabling one test to see effect on buildbots.
........
r78031 | vinay.sajip | 2010-02-06 14:28:36 -0600 (Sat, 06 Feb 2010) | 1 line
Issue #7857: Gave server thread more time to get ready, and re-enabled a skipped test.
........
r78032 | georg.brandl | 2010-02-06 15:54:40 -0600 (Sat, 06 Feb 2010) | 1 line
Remove unused imports from test_logging.
........
r78033 | benjamin.peterson | 2010-02-06 16:08:15 -0600 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78081 | vinay.sajip | 2010-02-07 06:56:54 -0600 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 07:06:51 -0600 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78103 | vinay.sajip | 2010-02-08 00:50:14 -0600 (Mon, 08 Feb 2010) | 1 line
Removed spurious print statement in test.
........
r78105 | vinay.sajip | 2010-02-08 09:32:08 -0600 (Mon, 08 Feb 2010) | 1 line
logging: skipped listening tests because they're not working reliably.
........
r78106 | vinay.sajip | 2010-02-08 10:05:50 -0600 (Mon, 08 Feb 2010) | 1 line
Issue #7857: Another attempt to keep the buildbots happy.
........
r78108 | vinay.sajip | 2010-02-08 15:18:15 -0600 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
r78246 | vinay.sajip | 2010-02-19 17:53:17 -0600 (Fri, 19 Feb 2010) | 1 line
logging: Documented warnings module integration.
........
r78703 | vinay.sajip | 2010-03-05 16:11:24 -0600 (Fri, 05 Mar 2010) | 1 line
Factored out time usage determination into a method, to facilitate alternative formatting implementations in the future.
........
r78728 | vinay.sajip | 2010-03-06 09:12:08 -0600 (Sat, 06 Mar 2010) | 1 line
Added schema version test in dictConfig.
........
r78731 | vinay.sajip | 2010-03-06 09:56:03 -0600 (Sat, 06 Mar 2010) | 1 line
Added checks for tuples in dictConfig.
........
r78853 | vinay.sajip | 2010-03-12 00:01:21 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: logging: Improved algorithm for computing initial rollover time.
........
r78855 | vinay.sajip | 2010-03-12 03:16:10 -0600 (Fri, 12 Mar 2010) | 1 line
Issue #8117: Updated NEWS entry and added to logging documentation.
........
2010-03-13 18:30:34 -04:00
|
|
|
text = text.encode("utf-8")
|
2010-08-15 17:16:27 -03:00
|
|
|
# Ask for a randomly assigned port (by using port 0)
|
2012-10-02 11:56:16 -03:00
|
|
|
t = logging.config.listen(0, verify)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
t.start()
|
|
|
|
t.ready.wait()
|
2010-06-27 17:54:28 -03:00
|
|
|
# Now get the port allocated
|
|
|
|
port = t.port
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
t.ready.clear()
|
|
|
|
try:
|
|
|
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
|
|
sock.settimeout(2.0)
|
|
|
|
sock.connect(('localhost', port))
|
|
|
|
|
|
|
|
slen = struct.pack('>L', len(text))
|
|
|
|
s = slen + text
|
|
|
|
sentsofar = 0
|
|
|
|
left = len(s)
|
|
|
|
while left > 0:
|
|
|
|
sent = sock.send(s[sentsofar:])
|
|
|
|
sentsofar += sent
|
|
|
|
left -= sent
|
|
|
|
sock.close()
|
|
|
|
finally:
|
|
|
|
t.ready.wait(2.0)
|
|
|
|
logging.config.stopListening()
|
2020-05-27 19:10:27 -03:00
|
|
|
threading_helper.join_thread(t)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def test_listen_config_10_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.setup_via_listener(json.dumps(self.config10))
|
2022-06-07 05:20:35 -03:00
|
|
|
self.check_handler('hand1', logging.StreamHandler)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger('compiler')
|
2017-12-14 07:04:53 -04:00
|
|
|
# Not output, because filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger('compiler.lexer')
|
2017-12-14 07:04:53 -04:00
|
|
|
# Not output, because filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.warning(self.next_message())
|
|
|
|
logger = logging.getLogger("compiler.parser.codegen")
|
2017-12-14 07:04:53 -04:00
|
|
|
# Output, as not filtered
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('WARNING', '1'),
|
|
|
|
('ERROR', '4'),
|
|
|
|
], stream=output)
|
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
def test_listen_config_1_ok(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
self.setup_via_listener(textwrap.dedent(ConfigFileTest.config1))
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output is empty.
|
|
|
|
self.assert_log_lines([])
|
|
|
|
|
2022-03-22 07:04:36 -03:00
|
|
|
@support.requires_working_socket()
|
2012-10-02 11:56:16 -03:00
|
|
|
def test_listen_verify(self):
|
|
|
|
|
|
|
|
def verify_fail(stuff):
|
|
|
|
return None
|
|
|
|
|
|
|
|
def verify_reverse(stuff):
|
|
|
|
return stuff[::-1]
|
|
|
|
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
to_send = textwrap.dedent(ConfigFileTest.config1)
|
|
|
|
# First, specify a verification function that will fail.
|
|
|
|
# We expect to see no output, since our configuration
|
|
|
|
# never took effect.
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2012-10-02 11:56:16 -03:00
|
|
|
self.setup_via_listener(to_send, verify_fail)
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([], stream=output)
|
|
|
|
# Original logger output has the stuff we logged.
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
2012-10-02 13:45:00 -03:00
|
|
|
], pat=r"^[\w.]+ -> (\w+): (\d+)$")
|
2012-10-02 11:56:16 -03:00
|
|
|
|
|
|
|
# Now, perform no verification. Our configuration
|
|
|
|
# should take effect.
|
|
|
|
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2012-10-02 11:56:16 -03:00
|
|
|
self.setup_via_listener(to_send) # no verify callable specified
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '3'),
|
|
|
|
('ERROR', '4'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output still has the stuff we logged before.
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
2012-10-02 13:45:00 -03:00
|
|
|
], pat=r"^[\w.]+ -> (\w+): (\d+)$")
|
2012-10-02 11:56:16 -03:00
|
|
|
|
|
|
|
# Now, perform verification which transforms the bytes.
|
|
|
|
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2012-10-02 11:56:16 -03:00
|
|
|
self.setup_via_listener(to_send[::-1], verify_reverse)
|
|
|
|
logger = logging.getLogger("compiler.parser")
|
|
|
|
# Both will output a message
|
|
|
|
logger.info(self.next_message())
|
|
|
|
logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '5'),
|
|
|
|
('ERROR', '6'),
|
|
|
|
], stream=output)
|
|
|
|
# Original logger output still has the stuff we logged before.
|
|
|
|
self.assert_log_lines([
|
|
|
|
('INFO', '1'),
|
|
|
|
('ERROR', '2'),
|
2012-10-02 13:45:00 -03:00
|
|
|
], pat=r"^[\w.]+ -> (\w+): (\d+)$")
|
2012-10-02 11:56:16 -03:00
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
def test_bad_format(self):
|
|
|
|
self.assertRaises(ValueError, self.apply_config, self.bad_format)
|
2018-10-15 15:41:36 -03:00
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
def test_bad_format_with_dollar_style(self):
|
|
|
|
config = copy.deepcopy(self.bad_format)
|
2018-10-15 15:41:36 -03:00
|
|
|
config['formatters']['mySimpleFormatter']['format'] = "${asctime} (${name}) ${levelname}: ${message}"
|
|
|
|
|
|
|
|
self.apply_config(config)
|
2013-03-22 12:19:54 -03:00
|
|
|
handler = logging.getLogger('mymodule').handlers[0]
|
|
|
|
self.assertIsInstance(handler.target, logging.Handler)
|
2013-03-29 14:56:54 -03:00
|
|
|
self.assertIsInstance(handler.formatter._style,
|
|
|
|
logging.StringTemplateStyle)
|
2022-06-07 05:20:35 -03:00
|
|
|
self.assertEqual(sorted(logging.getHandlerNames()),
|
|
|
|
['bufferGlobal', 'fileGlobal'])
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
2018-10-15 15:41:36 -03:00
|
|
|
def test_custom_formatter_class_with_validate(self):
|
|
|
|
self.apply_config(self.custom_formatter_class_validate)
|
|
|
|
handler = logging.getLogger("my_test_logger_custom_formatter").handlers[0]
|
|
|
|
self.assertIsInstance(handler.formatter, ExceptionFormatter)
|
|
|
|
|
|
|
|
def test_custom_formatter_class_with_validate2(self):
|
|
|
|
self.apply_config(self.custom_formatter_class_validate2)
|
|
|
|
handler = logging.getLogger("my_test_logger_custom_formatter").handlers[0]
|
|
|
|
self.assertIsInstance(handler.formatter, ExceptionFormatter)
|
|
|
|
|
|
|
|
def test_custom_formatter_class_with_validate2_with_wrong_fmt(self):
|
|
|
|
config = self.custom_formatter_class_validate.copy()
|
|
|
|
config['formatters']['form1']['style'] = "$"
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
# Exception should not be raised as we have configured 'validate' to False
|
2018-10-15 15:41:36 -03:00
|
|
|
self.apply_config(config)
|
|
|
|
handler = logging.getLogger("my_test_logger_custom_formatter").handlers[0]
|
|
|
|
self.assertIsInstance(handler.formatter, ExceptionFormatter)
|
|
|
|
|
|
|
|
def test_custom_formatter_class_with_validate3(self):
|
|
|
|
self.assertRaises(ValueError, self.apply_config, self.custom_formatter_class_validate3)
|
|
|
|
|
|
|
|
def test_custom_formatter_function_with_validate(self):
|
|
|
|
self.assertRaises(ValueError, self.apply_config, self.custom_formatter_with_function)
|
|
|
|
|
2023-04-12 04:35:56 -03:00
|
|
|
def test_custom_formatter_function_with_defaults(self):
|
|
|
|
self.assertRaises(ValueError, self.apply_config, self.custom_formatter_with_defaults)
|
|
|
|
|
2011-04-26 16:05:24 -03:00
|
|
|
def test_baseconfig(self):
|
|
|
|
d = {
|
|
|
|
'atuple': (1, 2, 3),
|
|
|
|
'alist': ['a', 'b', 'c'],
|
2023-08-25 05:15:26 -03:00
|
|
|
'adict': {
|
|
|
|
'd': 'e', 'f': 3 ,
|
|
|
|
'alpha numeric 1 with spaces' : 5,
|
|
|
|
'aplha numeric 1 %( - © ©ß¯' : 9,
|
|
|
|
'alpha numeric ] 1 with spaces' : 15,
|
|
|
|
'aplha ]] numeric 1 %( - © ©ß¯]' : 19,
|
|
|
|
' aplha [ numeric 1 %( - © ©ß¯] ' : 11,
|
|
|
|
' aplha ' : 32,
|
|
|
|
'' : 10,
|
|
|
|
'nest4' : {
|
|
|
|
'd': 'e', 'f': 3 ,
|
|
|
|
'alpha numeric 1 with spaces' : 5,
|
|
|
|
'aplha numeric 1 %( - © ©ß¯' : 9,
|
|
|
|
'' : 10,
|
|
|
|
'somelist' : ('g', ('h', 'i'), 'j'),
|
|
|
|
'somedict' : {
|
|
|
|
'a' : 1,
|
|
|
|
'a with 1 and space' : 3,
|
|
|
|
'a with ( and space' : 4,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2011-04-26 16:05:24 -03:00
|
|
|
'nest1': ('g', ('h', 'i'), 'j'),
|
|
|
|
'nest2': ['k', ['l', 'm'], 'n'],
|
|
|
|
'nest3': ['o', 'cfg://alist', 'p'],
|
|
|
|
}
|
|
|
|
bc = logging.config.BaseConfigurator(d)
|
|
|
|
self.assertEqual(bc.convert('cfg://atuple[1]'), 2)
|
|
|
|
self.assertEqual(bc.convert('cfg://alist[1]'), 'b')
|
|
|
|
self.assertEqual(bc.convert('cfg://nest1[1][0]'), 'h')
|
|
|
|
self.assertEqual(bc.convert('cfg://nest2[1][1]'), 'm')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.d'), 'e')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[f]'), 3)
|
2023-08-25 05:15:26 -03:00
|
|
|
self.assertEqual(bc.convert('cfg://adict[alpha numeric 1 with spaces]'), 5)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[aplha numeric 1 %( - © ©ß¯]'), 9)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[]'), 10)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4.d'), 'e')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4[d]'), 'e')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4].d'), 'e')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][f]'), 3)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][alpha numeric 1 with spaces]'), 5)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][aplha numeric 1 %( - © ©ß¯]'), 9)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][]'), 10)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][somelist][0]'), 'g')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][somelist][1][0]'), 'h')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][somelist][1][1]'), 'i')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4][somelist][2]'), 'j')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4].somedict.a'), 1)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4].somedict[a]'), 1)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4].somedict[a with 1 and space]'), 3)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict[nest4].somedict[a with ( and space]'), 4)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4.somelist[1][1]'), 'i')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4.somelist[2]'), 'j')
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4.somedict.a'), 1)
|
|
|
|
self.assertEqual(bc.convert('cfg://adict.nest4.somedict[a]'), 1)
|
2011-04-26 16:05:24 -03:00
|
|
|
v = bc.convert('cfg://nest3')
|
|
|
|
self.assertEqual(v.pop(1), ['a', 'b', 'c'])
|
|
|
|
self.assertRaises(KeyError, bc.convert, 'cfg://nosuch')
|
|
|
|
self.assertRaises(ValueError, bc.convert, 'cfg://!')
|
|
|
|
self.assertRaises(KeyError, bc.convert, 'cfg://adict[2]')
|
2023-08-25 05:15:26 -03:00
|
|
|
self.assertRaises(KeyError, bc.convert, 'cfg://adict[alpha numeric ] 1 with spaces]')
|
|
|
|
self.assertRaises(ValueError, bc.convert, 'cfg://adict[ aplha ]] numeric 1 %( - © ©ß¯] ]')
|
|
|
|
self.assertRaises(ValueError, bc.convert, 'cfg://adict[ aplha [ numeric 1 %( - © ©ß¯] ]')
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
2020-01-01 15:32:11 -04:00
|
|
|
def test_namedtuple(self):
|
|
|
|
# see bpo-39142
|
|
|
|
from collections import namedtuple
|
|
|
|
|
|
|
|
class MyHandler(logging.StreamHandler):
|
|
|
|
def __init__(self, resource, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.resource: namedtuple = resource
|
|
|
|
|
|
|
|
def emit(self, record):
|
|
|
|
record.msg += f' {self.resource.type}'
|
|
|
|
return super().emit(record)
|
|
|
|
|
|
|
|
Resource = namedtuple('Resource', ['type', 'labels'])
|
|
|
|
resource = Resource(type='my_type', labels=['a'])
|
|
|
|
|
|
|
|
config = {
|
|
|
|
'version': 1,
|
|
|
|
'handlers': {
|
|
|
|
'myhandler': {
|
|
|
|
'()': MyHandler,
|
|
|
|
'resource': resource
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'root': {'level': 'INFO', 'handlers': ['myhandler']},
|
|
|
|
}
|
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
self.apply_config(config)
|
|
|
|
logging.info('some log')
|
|
|
|
self.assertEqual(stderr.getvalue(), 'some log my_type\n')
|
|
|
|
|
2022-01-24 08:39:50 -04:00
|
|
|
def test_config_callable_filter_works(self):
|
|
|
|
def filter_(_):
|
|
|
|
return 1
|
|
|
|
self.apply_config({
|
|
|
|
"version": 1, "root": {"level": "DEBUG", "filters": [filter_]}
|
|
|
|
})
|
|
|
|
assert logging.getLogger().filters[0] is filter_
|
|
|
|
logging.getLogger().filters = []
|
|
|
|
|
|
|
|
def test_config_filter_works(self):
|
|
|
|
filter_ = logging.Filter("spam.eggs")
|
|
|
|
self.apply_config({
|
|
|
|
"version": 1, "root": {"level": "DEBUG", "filters": [filter_]}
|
|
|
|
})
|
|
|
|
assert logging.getLogger().filters[0] is filter_
|
|
|
|
logging.getLogger().filters = []
|
|
|
|
|
|
|
|
def test_config_filter_method_works(self):
|
|
|
|
class FakeFilter:
|
|
|
|
def filter(self, _):
|
|
|
|
return 1
|
|
|
|
filter_ = FakeFilter()
|
|
|
|
self.apply_config({
|
|
|
|
"version": 1, "root": {"level": "DEBUG", "filters": [filter_]}
|
|
|
|
})
|
|
|
|
assert logging.getLogger().filters[0] is filter_
|
|
|
|
logging.getLogger().filters = []
|
|
|
|
|
|
|
|
def test_invalid_type_raises(self):
|
|
|
|
class NotAFilter: pass
|
|
|
|
for filter_ in [None, 1, NotAFilter()]:
|
|
|
|
self.assertRaises(
|
|
|
|
ValueError,
|
|
|
|
self.apply_config,
|
|
|
|
{"version": 1, "root": {"level": "DEBUG", "filters": [filter_]}}
|
|
|
|
)
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
def do_queuehandler_configuration(self, qspec, lspec):
|
|
|
|
cd = copy.deepcopy(self.config_queue_handler)
|
|
|
|
fn = make_temp_file('.log', 'test_logging-cqh-')
|
|
|
|
cd['handlers']['h1']['filename'] = fn
|
|
|
|
if qspec is not None:
|
|
|
|
cd['handlers']['ah']['queue'] = qspec
|
|
|
|
if lspec is not None:
|
|
|
|
cd['handlers']['ah']['listener'] = lspec
|
|
|
|
qh = None
|
|
|
|
try:
|
|
|
|
self.apply_config(cd)
|
|
|
|
qh = logging.getHandlerByName('ah')
|
|
|
|
self.assertEqual(sorted(logging.getHandlerNames()), ['ah', 'h1'])
|
|
|
|
self.assertIsNotNone(qh.listener)
|
|
|
|
qh.listener.start()
|
|
|
|
logging.debug('foo')
|
|
|
|
logging.info('bar')
|
|
|
|
logging.warning('baz')
|
2022-06-15 09:09:56 -03:00
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
# Need to let the listener thread finish its work
|
2022-06-16 08:44:58 -03:00
|
|
|
while support.sleeping_retry(support.LONG_TIMEOUT,
|
|
|
|
"queue not empty"):
|
2022-06-15 09:09:56 -03:00
|
|
|
if qh.listener.queue.empty():
|
|
|
|
break
|
|
|
|
|
2022-06-19 06:49:35 -03:00
|
|
|
# wait until the handler completed its last task
|
|
|
|
qh.listener.queue.join()
|
|
|
|
|
2022-06-07 05:20:35 -03:00
|
|
|
with open(fn, encoding='utf-8') as f:
|
|
|
|
data = f.read().splitlines()
|
|
|
|
self.assertEqual(data, ['foo', 'bar', 'baz'])
|
|
|
|
finally:
|
|
|
|
if qh:
|
|
|
|
qh.listener.stop()
|
|
|
|
h = logging.getHandlerByName('h1')
|
|
|
|
if h:
|
|
|
|
self.addCleanup(closeFileHandler, h, fn)
|
|
|
|
else:
|
|
|
|
self.addCleanup(os.remove, fn)
|
|
|
|
|
2022-06-07 07:34:08 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2022-06-07 05:20:35 -03:00
|
|
|
def test_config_queue_handler(self):
|
|
|
|
q = CustomQueue()
|
|
|
|
dq = {
|
|
|
|
'()': __name__ + '.CustomQueue',
|
|
|
|
'maxsize': 10
|
|
|
|
}
|
|
|
|
dl = {
|
|
|
|
'()': __name__ + '.listenerMaker',
|
|
|
|
'arg1': None,
|
|
|
|
'arg2': None,
|
|
|
|
'respect_handler_level': True
|
|
|
|
}
|
|
|
|
qvalues = (None, __name__ + '.queueMaker', __name__ + '.CustomQueue', dq, q)
|
|
|
|
lvalues = (None, __name__ + '.CustomListener', dl, CustomListener)
|
|
|
|
for qspec, lspec in itertools.product(qvalues, lvalues):
|
|
|
|
self.do_queuehandler_configuration(qspec, lspec)
|
|
|
|
|
|
|
|
# Some failure cases
|
|
|
|
qvalues = (None, 4, int, '', 'foo')
|
|
|
|
lvalues = (None, 4, int, '', 'bar')
|
|
|
|
for qspec, lspec in itertools.product(qvalues, lvalues):
|
|
|
|
if lspec is None and qspec is None:
|
|
|
|
continue
|
|
|
|
with self.assertRaises(ValueError) as ctx:
|
|
|
|
self.do_queuehandler_configuration(qspec, lspec)
|
|
|
|
msg = str(ctx.exception)
|
|
|
|
self.assertEqual(msg, "Unable to configure handler 'ah'")
|
|
|
|
|
2022-09-03 09:38:38 -03:00
|
|
|
def test_90195(self):
|
|
|
|
# See gh-90195
|
|
|
|
config = {
|
|
|
|
'version': 1,
|
|
|
|
'disable_existing_loggers': False,
|
|
|
|
'handlers': {
|
|
|
|
'console': {
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'class': 'logging.StreamHandler',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'loggers': {
|
|
|
|
'a': {
|
|
|
|
'level': 'DEBUG',
|
|
|
|
'handlers': ['console']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
logger = logging.getLogger('a')
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
self.apply_config(config)
|
|
|
|
self.assertFalse(logger.disabled)
|
|
|
|
# Should disable all loggers ...
|
|
|
|
self.apply_config({'version': 1})
|
|
|
|
self.assertTrue(logger.disabled)
|
|
|
|
del config['disable_existing_loggers']
|
|
|
|
self.apply_config(config)
|
|
|
|
# Logger should be enabled, since explicitly mentioned
|
|
|
|
self.assertFalse(logger.disabled)
|
2022-01-24 08:39:50 -04:00
|
|
|
|
2023-12-27 05:35:15 -04:00
|
|
|
def test_111615(self):
|
|
|
|
# See gh-111615
|
2024-01-09 03:47:42 -04:00
|
|
|
import_helper.import_module('_multiprocessing') # see gh-113692
|
|
|
|
mp = import_helper.import_module('multiprocessing')
|
2023-12-27 05:35:15 -04:00
|
|
|
|
|
|
|
config = {
|
|
|
|
'version': 1,
|
|
|
|
'handlers': {
|
|
|
|
'sink': {
|
|
|
|
'class': 'logging.handlers.QueueHandler',
|
|
|
|
'queue': mp.get_context('spawn').Queue(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'root': {
|
|
|
|
'handlers': ['sink'],
|
|
|
|
'level': 'DEBUG',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
logging.config.dictConfig(config)
|
|
|
|
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
class ManagerTest(BaseTest):
|
|
|
|
def test_manager_loggerclass(self):
|
|
|
|
logged = []
|
|
|
|
|
|
|
|
class MyLogger(logging.Logger):
|
|
|
|
def _log(self, level, msg, args, exc_info=None, extra=None):
|
|
|
|
logged.append(msg)
|
|
|
|
|
|
|
|
man = logging.Manager(None)
|
|
|
|
self.assertRaises(TypeError, man.setLoggerClass, int)
|
|
|
|
man.setLoggerClass(MyLogger)
|
|
|
|
logger = man.getLogger('test')
|
|
|
|
logger.warning('should appear in logged')
|
|
|
|
logging.warning('should not appear in logged')
|
|
|
|
|
|
|
|
self.assertEqual(logged, ['should appear in logged'])
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def test_set_log_record_factory(self):
|
|
|
|
man = logging.Manager(None)
|
|
|
|
expected = object()
|
|
|
|
man.setLogRecordFactory(expected)
|
|
|
|
self.assertEqual(man.logRecordFactory, expected)
|
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line
Logging: Implemented PEP 391.
........
r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line
Removed spurious print statement.
........
r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line
make waiting for the server to start robust
........
r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7868: logging: added loggerClass attribute to Manager.
........
r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line
Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code.
........
r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line
logging: Removed some more 1.5.2 support code.
........
r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line
logging: gingerly re-enabling skipped tests after improving thread sync code in configurator.
........
2010-02-25 19:13:06 -04:00
|
|
|
|
Merged revisions 79279,79284,79293,79373,79376,79379,79876,79888 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79279 | vinay.sajip | 2010-03-22 07:33:08 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8200: logging: Handle errors when multiprocessing is not fully loaded when logging occurs.
........
r79284 | vinay.sajip | 2010-03-22 08:02:28 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8201: logging: Handle config errors when non-ASCII and Unicode logger names exist at the same time.
........
r79293 | vinay.sajip | 2010-03-22 10:29:01 -0500 (Mon, 22 Mar 2010) | 1 line
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
........
r79373 | vinay.sajip | 2010-03-24 09:31:21 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Added LOG_FTP for SysLogHandler and updated documentation.
........
r79376 | vinay.sajip | 2010-03-24 10:10:40 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Documentation tweak.
........
r79379 | vinay.sajip | 2010-03-24 12:36:35 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Updated SysLogHandler documentation.
........
r79876 | vinay.sajip | 2010-04-06 17:32:37 -0500 (Tue, 06 Apr 2010) | 1 line
Issue #8327: logging: Clarification of propagation functionality in documentation.
........
r79888 | vinay.sajip | 2010-04-07 04:40:52 -0500 (Wed, 07 Apr 2010) | 1 line
Issue #8331: logging: fixed some grammatical errors in documentation.
........
2010-04-11 13:25:06 -03:00
|
|
|
class ChildLoggerTest(BaseTest):
|
|
|
|
def test_child_loggers(self):
|
|
|
|
r = logging.getLogger()
|
|
|
|
l1 = logging.getLogger('abc')
|
|
|
|
l2 = logging.getLogger('def.ghi')
|
|
|
|
c1 = r.getChild('xyz')
|
|
|
|
c2 = r.getChild('uvw.xyz')
|
2012-10-17 08:24:27 -03:00
|
|
|
self.assertIs(c1, logging.getLogger('xyz'))
|
|
|
|
self.assertIs(c2, logging.getLogger('uvw.xyz'))
|
Merged revisions 79279,79284,79293,79373,79376,79379,79876,79888 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79279 | vinay.sajip | 2010-03-22 07:33:08 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8200: logging: Handle errors when multiprocessing is not fully loaded when logging occurs.
........
r79284 | vinay.sajip | 2010-03-22 08:02:28 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8201: logging: Handle config errors when non-ASCII and Unicode logger names exist at the same time.
........
r79293 | vinay.sajip | 2010-03-22 10:29:01 -0500 (Mon, 22 Mar 2010) | 1 line
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
........
r79373 | vinay.sajip | 2010-03-24 09:31:21 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Added LOG_FTP for SysLogHandler and updated documentation.
........
r79376 | vinay.sajip | 2010-03-24 10:10:40 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Documentation tweak.
........
r79379 | vinay.sajip | 2010-03-24 12:36:35 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Updated SysLogHandler documentation.
........
r79876 | vinay.sajip | 2010-04-06 17:32:37 -0500 (Tue, 06 Apr 2010) | 1 line
Issue #8327: logging: Clarification of propagation functionality in documentation.
........
r79888 | vinay.sajip | 2010-04-07 04:40:52 -0500 (Wed, 07 Apr 2010) | 1 line
Issue #8331: logging: fixed some grammatical errors in documentation.
........
2010-04-11 13:25:06 -03:00
|
|
|
c1 = l1.getChild('def')
|
|
|
|
c2 = c1.getChild('ghi')
|
|
|
|
c3 = l1.getChild('def.ghi')
|
2012-10-17 08:24:27 -03:00
|
|
|
self.assertIs(c1, logging.getLogger('abc.def'))
|
|
|
|
self.assertIs(c2, logging.getLogger('abc.def.ghi'))
|
|
|
|
self.assertIs(c2, c3)
|
Merged revisions 79279,79284,79293,79373,79376,79379,79876,79888 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79279 | vinay.sajip | 2010-03-22 07:33:08 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8200: logging: Handle errors when multiprocessing is not fully loaded when logging occurs.
........
r79284 | vinay.sajip | 2010-03-22 08:02:28 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8201: logging: Handle config errors when non-ASCII and Unicode logger names exist at the same time.
........
r79293 | vinay.sajip | 2010-03-22 10:29:01 -0500 (Mon, 22 Mar 2010) | 1 line
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
........
r79373 | vinay.sajip | 2010-03-24 09:31:21 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Added LOG_FTP for SysLogHandler and updated documentation.
........
r79376 | vinay.sajip | 2010-03-24 10:10:40 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Documentation tweak.
........
r79379 | vinay.sajip | 2010-03-24 12:36:35 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Updated SysLogHandler documentation.
........
r79876 | vinay.sajip | 2010-04-06 17:32:37 -0500 (Tue, 06 Apr 2010) | 1 line
Issue #8327: logging: Clarification of propagation functionality in documentation.
........
r79888 | vinay.sajip | 2010-04-07 04:40:52 -0500 (Wed, 07 Apr 2010) | 1 line
Issue #8331: logging: fixed some grammatical errors in documentation.
........
2010-04-11 13:25:06 -03:00
|
|
|
|
2022-08-31 06:50:29 -03:00
|
|
|
def test_get_children(self):
|
|
|
|
r = logging.getLogger()
|
|
|
|
l1 = logging.getLogger('foo')
|
|
|
|
l2 = logging.getLogger('foo.bar')
|
|
|
|
l3 = logging.getLogger('foo.bar.baz.bozz')
|
|
|
|
l4 = logging.getLogger('bar')
|
|
|
|
kids = r.getChildren()
|
|
|
|
expected = {l1, l4}
|
|
|
|
self.assertEqual(expected, kids & expected) # might be other kids for root
|
|
|
|
self.assertNotIn(l2, expected)
|
|
|
|
kids = l1.getChildren()
|
|
|
|
self.assertEqual({l2}, kids)
|
|
|
|
kids = l2.getChildren()
|
|
|
|
self.assertEqual(set(), kids)
|
Merged revisions 79279,79284,79293,79373,79376,79379,79876,79888 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79279 | vinay.sajip | 2010-03-22 07:33:08 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8200: logging: Handle errors when multiprocessing is not fully loaded when logging occurs.
........
r79284 | vinay.sajip | 2010-03-22 08:02:28 -0500 (Mon, 22 Mar 2010) | 1 line
Issue #8201: logging: Handle config errors when non-ASCII and Unicode logger names exist at the same time.
........
r79293 | vinay.sajip | 2010-03-22 10:29:01 -0500 (Mon, 22 Mar 2010) | 1 line
logging: Added getChild utility method to Logger and added isEnabledFor method to LoggerAdapter.
........
r79373 | vinay.sajip | 2010-03-24 09:31:21 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Added LOG_FTP for SysLogHandler and updated documentation.
........
r79376 | vinay.sajip | 2010-03-24 10:10:40 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Documentation tweak.
........
r79379 | vinay.sajip | 2010-03-24 12:36:35 -0500 (Wed, 24 Mar 2010) | 1 line
logging: Updated SysLogHandler documentation.
........
r79876 | vinay.sajip | 2010-04-06 17:32:37 -0500 (Tue, 06 Apr 2010) | 1 line
Issue #8327: logging: Clarification of propagation functionality in documentation.
........
r79888 | vinay.sajip | 2010-04-07 04:40:52 -0500 (Wed, 07 Apr 2010) | 1 line
Issue #8331: logging: fixed some grammatical errors in documentation.
........
2010-04-11 13:25:06 -03:00
|
|
|
|
2010-10-19 17:44:14 -03:00
|
|
|
class DerivedLogRecord(logging.LogRecord):
|
|
|
|
pass
|
|
|
|
|
2010-12-03 07:50:38 -04:00
|
|
|
class LogRecordFactoryTest(BaseTest):
|
2010-10-19 17:44:14 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
class CheckingFilter(logging.Filter):
|
|
|
|
def __init__(self, cls):
|
|
|
|
self.cls = cls
|
|
|
|
|
|
|
|
def filter(self, record):
|
|
|
|
t = type(record)
|
|
|
|
if t is not self.cls:
|
|
|
|
msg = 'Unexpected LogRecord type %s, expected %s' % (t,
|
|
|
|
self.cls)
|
|
|
|
raise TypeError(msg)
|
|
|
|
return True
|
|
|
|
|
|
|
|
BaseTest.setUp(self)
|
|
|
|
self.filter = CheckingFilter(DerivedLogRecord)
|
|
|
|
self.root_logger.addFilter(self.filter)
|
2010-12-03 07:50:38 -04:00
|
|
|
self.orig_factory = logging.getLogRecordFactory()
|
2010-10-19 17:44:14 -03:00
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.root_logger.removeFilter(self.filter)
|
|
|
|
BaseTest.tearDown(self)
|
2010-12-03 07:50:38 -04:00
|
|
|
logging.setLogRecordFactory(self.orig_factory)
|
2010-10-19 17:44:14 -03:00
|
|
|
|
|
|
|
def test_logrecord_class(self):
|
|
|
|
self.assertRaises(TypeError, self.root_logger.warning,
|
|
|
|
self.next_message())
|
2010-12-03 07:50:38 -04:00
|
|
|
logging.setLogRecordFactory(DerivedLogRecord)
|
2010-10-19 17:44:14 -03:00
|
|
|
self.root_logger.error(self.next_message())
|
|
|
|
self.assert_log_lines([
|
|
|
|
('root', 'ERROR', '2'),
|
|
|
|
])
|
|
|
|
|
|
|
|
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2010-09-14 06:34:09 -03:00
|
|
|
class QueueHandlerTest(BaseTest):
|
|
|
|
# Do not bother with a logger name group.
|
2012-10-02 13:45:00 -03:00
|
|
|
expected_log_pat = r"^[\w.]+ -> (\w+): (\d+)$"
|
2010-09-14 06:34:09 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
BaseTest.setUp(self)
|
|
|
|
self.queue = queue.Queue(-1)
|
|
|
|
self.que_hdlr = logging.handlers.QueueHandler(self.queue)
|
2017-08-01 15:12:26 -03:00
|
|
|
self.name = 'que'
|
2010-09-14 06:34:09 -03:00
|
|
|
self.que_logger = logging.getLogger('que')
|
|
|
|
self.que_logger.propagate = False
|
|
|
|
self.que_logger.setLevel(logging.WARNING)
|
|
|
|
self.que_logger.addHandler(self.que_hdlr)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
self.que_hdlr.close()
|
|
|
|
BaseTest.tearDown(self)
|
|
|
|
|
|
|
|
def test_queue_handler(self):
|
|
|
|
self.que_logger.debug(self.next_message())
|
|
|
|
self.assertRaises(queue.Empty, self.queue.get_nowait)
|
|
|
|
self.que_logger.info(self.next_message())
|
|
|
|
self.assertRaises(queue.Empty, self.queue.get_nowait)
|
|
|
|
msg = self.next_message()
|
|
|
|
self.que_logger.warning(msg)
|
|
|
|
data = self.queue.get_nowait()
|
|
|
|
self.assertTrue(isinstance(data, logging.LogRecord))
|
|
|
|
self.assertEqual(data.name, self.que_logger.name)
|
|
|
|
self.assertEqual((data.msg, data.args), (msg, None))
|
|
|
|
|
2017-08-01 15:12:26 -03:00
|
|
|
def test_formatting(self):
|
|
|
|
msg = self.next_message()
|
|
|
|
levelname = logging.getLevelName(logging.WARNING)
|
|
|
|
log_format_str = '{name} -> {levelname}: {message}'
|
|
|
|
formatted_msg = log_format_str.format(name=self.name,
|
|
|
|
levelname=levelname, message=msg)
|
|
|
|
formatter = logging.Formatter(self.log_format)
|
|
|
|
self.que_hdlr.setFormatter(formatter)
|
|
|
|
self.que_logger.warning(msg)
|
|
|
|
log_record = self.queue.get_nowait()
|
|
|
|
self.assertEqual(formatted_msg, log_record.msg)
|
|
|
|
self.assertEqual(formatted_msg, log_record.message)
|
|
|
|
|
2011-05-02 11:11:28 -03:00
|
|
|
@unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
|
|
|
|
'logging.handlers.QueueListener required for this test')
|
2011-04-15 18:27:17 -03:00
|
|
|
def test_queue_listener(self):
|
2020-04-25 05:35:18 -03:00
|
|
|
handler = TestHandler(support.Matcher())
|
2011-04-15 18:27:17 -03:00
|
|
|
listener = logging.handlers.QueueListener(self.queue, handler)
|
|
|
|
listener.start()
|
|
|
|
try:
|
|
|
|
self.que_logger.warning(self.next_message())
|
|
|
|
self.que_logger.error(self.next_message())
|
|
|
|
self.que_logger.critical(self.next_message())
|
|
|
|
finally:
|
|
|
|
listener.stop()
|
2024-01-30 08:34:18 -04:00
|
|
|
listener.stop() # gh-114706 - ensure no crash if called again
|
2011-04-15 18:27:17 -03:00
|
|
|
self.assertTrue(handler.matches(levelno=logging.WARNING, message='1'))
|
|
|
|
self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
|
|
|
|
self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))
|
2015-02-09 15:49:00 -04:00
|
|
|
handler.close()
|
|
|
|
|
|
|
|
# Now test with respect_handler_level set
|
|
|
|
|
2020-04-25 05:35:18 -03:00
|
|
|
handler = TestHandler(support.Matcher())
|
2015-02-09 15:49:00 -04:00
|
|
|
handler.setLevel(logging.CRITICAL)
|
|
|
|
listener = logging.handlers.QueueListener(self.queue, handler,
|
|
|
|
respect_handler_level=True)
|
|
|
|
listener.start()
|
|
|
|
try:
|
|
|
|
self.que_logger.warning(self.next_message())
|
|
|
|
self.que_logger.error(self.next_message())
|
|
|
|
self.que_logger.critical(self.next_message())
|
|
|
|
finally:
|
|
|
|
listener.stop()
|
|
|
|
self.assertFalse(handler.matches(levelno=logging.WARNING, message='4'))
|
|
|
|
self.assertFalse(handler.matches(levelno=logging.ERROR, message='5'))
|
|
|
|
self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='6'))
|
2018-09-25 20:00:08 -03:00
|
|
|
handler.close()
|
|
|
|
|
|
|
|
@unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
|
|
|
|
'logging.handlers.QueueListener required for this test')
|
|
|
|
def test_queue_listener_with_StreamHandler(self):
|
2022-07-05 11:23:12 -03:00
|
|
|
# Test that traceback and stack-info only appends once (bpo-34334, bpo-46755).
|
2018-09-25 20:00:08 -03:00
|
|
|
listener = logging.handlers.QueueListener(self.queue, self.root_hdlr)
|
|
|
|
listener.start()
|
|
|
|
try:
|
|
|
|
1 / 0
|
|
|
|
except ZeroDivisionError as e:
|
|
|
|
exc = e
|
|
|
|
self.que_logger.exception(self.next_message(), exc_info=exc)
|
2022-07-05 11:23:12 -03:00
|
|
|
self.que_logger.error(self.next_message(), stack_info=True)
|
2018-09-25 20:00:08 -03:00
|
|
|
listener.stop()
|
|
|
|
self.assertEqual(self.stream.getvalue().strip().count('Traceback'), 1)
|
2022-07-05 11:23:12 -03:00
|
|
|
self.assertEqual(self.stream.getvalue().strip().count('Stack'), 1)
|
2015-02-09 15:49:00 -04:00
|
|
|
|
2019-04-07 04:51:27 -03:00
|
|
|
@unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
|
|
|
|
'logging.handlers.QueueListener required for this test')
|
|
|
|
def test_queue_listener_with_multiple_handlers(self):
|
|
|
|
# Test that queue handler format doesn't affect other handler formats (bpo-35726).
|
|
|
|
self.que_hdlr.setFormatter(self.root_formatter)
|
|
|
|
self.que_logger.addHandler(self.root_hdlr)
|
|
|
|
|
|
|
|
listener = logging.handlers.QueueListener(self.queue, self.que_hdlr)
|
|
|
|
listener.start()
|
|
|
|
self.que_logger.error("error")
|
|
|
|
listener.stop()
|
|
|
|
self.assertEqual(self.stream.getvalue().strip(), "que -> ERROR: error")
|
|
|
|
|
2016-09-07 21:13:39 -03:00
|
|
|
if hasattr(logging.handlers, 'QueueListener'):
|
|
|
|
import multiprocessing
|
|
|
|
from unittest.mock import patch
|
|
|
|
|
2022-04-07 04:22:47 -03:00
|
|
|
@threading_helper.requires_working_threading()
|
2016-09-07 21:13:39 -03:00
|
|
|
class QueueListenerTest(BaseTest):
|
|
|
|
"""
|
|
|
|
Tests based on patch submitted for issue #27930. Ensure that
|
|
|
|
QueueListener handles all log messages.
|
|
|
|
"""
|
|
|
|
|
|
|
|
repeat = 20
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def setup_and_log(log_queue, ident):
|
|
|
|
"""
|
|
|
|
Creates a logger with a QueueHandler that logs to a queue read by a
|
|
|
|
QueueListener. Starts the listener, logs five messages, and stops
|
|
|
|
the listener.
|
|
|
|
"""
|
|
|
|
logger = logging.getLogger('test_logger_with_id_%s' % ident)
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
handler = logging.handlers.QueueHandler(log_queue)
|
|
|
|
logger.addHandler(handler)
|
|
|
|
listener = logging.handlers.QueueListener(log_queue)
|
|
|
|
listener.start()
|
|
|
|
|
|
|
|
logger.info('one')
|
|
|
|
logger.info('two')
|
|
|
|
logger.info('three')
|
|
|
|
logger.info('four')
|
|
|
|
logger.info('five')
|
|
|
|
|
|
|
|
listener.stop()
|
|
|
|
logger.removeHandler(handler)
|
|
|
|
handler.close()
|
|
|
|
|
|
|
|
@patch.object(logging.handlers.QueueListener, 'handle')
|
|
|
|
def test_handle_called_with_queue_queue(self, mock_handle):
|
|
|
|
for i in range(self.repeat):
|
|
|
|
log_queue = queue.Queue()
|
|
|
|
self.setup_and_log(log_queue, '%s_%s' % (self.id(), i))
|
|
|
|
self.assertEqual(mock_handle.call_count, 5 * self.repeat,
|
|
|
|
'correct number of handled log messages')
|
|
|
|
|
|
|
|
@patch.object(logging.handlers.QueueListener, 'handle')
|
|
|
|
def test_handle_called_with_mp_queue(self, mock_handle):
|
2020-06-18 09:53:19 -03:00
|
|
|
# bpo-28668: The multiprocessing (mp) module is not functional
|
2017-12-01 03:08:49 -04:00
|
|
|
# when the mp.synchronize module cannot be imported.
|
2020-06-18 09:53:19 -03:00
|
|
|
support.skip_if_broken_multiprocessing_synchronize()
|
2016-09-07 21:13:39 -03:00
|
|
|
for i in range(self.repeat):
|
|
|
|
log_queue = multiprocessing.Queue()
|
|
|
|
self.setup_and_log(log_queue, '%s_%s' % (self.id(), i))
|
2017-04-26 10:56:25 -03:00
|
|
|
log_queue.close()
|
|
|
|
log_queue.join_thread()
|
2016-09-07 21:13:39 -03:00
|
|
|
self.assertEqual(mock_handle.call_count, 5 * self.repeat,
|
|
|
|
'correct number of handled log messages')
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_all_from_queue(log_queue):
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
yield log_queue.get_nowait()
|
|
|
|
except queue.Empty:
|
|
|
|
return []
|
|
|
|
|
|
|
|
def test_no_messages_in_queue_after_stop(self):
|
|
|
|
"""
|
|
|
|
Five messages are logged then the QueueListener is stopped. This
|
|
|
|
test then gets everything off the queue. Failure of this test
|
|
|
|
indicates that messages were not registered on the queue until
|
|
|
|
_after_ the QueueListener stopped.
|
|
|
|
"""
|
2020-06-18 09:53:19 -03:00
|
|
|
# bpo-28668: The multiprocessing (mp) module is not functional
|
2017-12-01 03:08:49 -04:00
|
|
|
# when the mp.synchronize module cannot be imported.
|
2020-06-18 09:53:19 -03:00
|
|
|
support.skip_if_broken_multiprocessing_synchronize()
|
2016-09-07 21:13:39 -03:00
|
|
|
for i in range(self.repeat):
|
|
|
|
queue = multiprocessing.Queue()
|
|
|
|
self.setup_and_log(queue, '%s_%s' %(self.id(), i))
|
|
|
|
# time.sleep(1)
|
|
|
|
items = list(self.get_all_from_queue(queue))
|
2017-04-26 10:56:25 -03:00
|
|
|
queue.close()
|
|
|
|
queue.join_thread()
|
|
|
|
|
2016-09-07 21:13:39 -03:00
|
|
|
expected = [[], [logging.handlers.QueueListener._sentinel]]
|
|
|
|
self.assertIn(items, expected,
|
|
|
|
'Found unexpected messages in queue: %s' % (
|
|
|
|
[m.msg if isinstance(m, logging.LogRecord)
|
|
|
|
else m for m in items]))
|
|
|
|
|
2019-06-01 06:19:09 -03:00
|
|
|
def test_calls_task_done_after_stop(self):
|
|
|
|
# Issue 36813: Make sure queue.join does not deadlock.
|
|
|
|
log_queue = queue.Queue()
|
|
|
|
listener = logging.handlers.QueueListener(log_queue)
|
|
|
|
listener.start()
|
|
|
|
listener.stop()
|
|
|
|
with self.assertRaises(ValueError):
|
|
|
|
# Make sure all tasks are done and .join won't block.
|
|
|
|
log_queue.task_done()
|
|
|
|
|
2011-04-15 18:27:17 -03:00
|
|
|
|
2011-04-26 16:26:41 -03:00
|
|
|
ZERO = datetime.timedelta(0)
|
|
|
|
|
|
|
|
class UTC(datetime.tzinfo):
|
|
|
|
def utcoffset(self, dt):
|
|
|
|
return ZERO
|
|
|
|
|
|
|
|
dst = utcoffset
|
|
|
|
|
|
|
|
def tzname(self, dt):
|
|
|
|
return 'UTC'
|
|
|
|
|
|
|
|
utc = UTC()
|
2011-04-15 18:27:17 -03:00
|
|
|
|
2020-09-25 15:08:50 -03:00
|
|
|
class AssertErrorMessage:
|
|
|
|
|
|
|
|
def assert_error_message(self, exception, message, *args, **kwargs):
|
|
|
|
try:
|
|
|
|
self.assertRaises((), *args, **kwargs)
|
|
|
|
except exception as e:
|
|
|
|
self.assertEqual(message, str(e))
|
|
|
|
|
|
|
|
class FormatterTest(unittest.TestCase, AssertErrorMessage):
|
2010-10-25 10:57:39 -03:00
|
|
|
def setUp(self):
|
|
|
|
self.common = {
|
|
|
|
'name': 'formatter.test',
|
|
|
|
'level': logging.DEBUG,
|
|
|
|
'pathname': os.path.join('path', 'to', 'dummy.ext'),
|
|
|
|
'lineno': 42,
|
|
|
|
'exc_info': None,
|
|
|
|
'func': None,
|
|
|
|
'msg': 'Message with %d %s',
|
|
|
|
'args': (2, 'placeholders'),
|
|
|
|
}
|
|
|
|
self.variants = {
|
2020-06-18 11:18:58 -03:00
|
|
|
'custom': {
|
|
|
|
'custom': 1234
|
|
|
|
}
|
2010-10-25 10:57:39 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
def get_record(self, name=None):
|
|
|
|
result = dict(self.common)
|
|
|
|
if name is not None:
|
|
|
|
result.update(self.variants[name])
|
|
|
|
return logging.makeLogRecord(result)
|
|
|
|
|
|
|
|
def test_percent(self):
|
2010-12-27 07:18:52 -04:00
|
|
|
# Test %-formatting
|
2010-10-25 10:57:39 -03:00
|
|
|
r = self.get_record()
|
|
|
|
f = logging.Formatter('${%(message)s}')
|
|
|
|
self.assertEqual(f.format(r), '${Message with 2 placeholders}')
|
|
|
|
f = logging.Formatter('%(random)s')
|
2018-10-15 15:41:36 -03:00
|
|
|
self.assertRaises(ValueError, f.format, r)
|
2010-10-26 10:16:11 -03:00
|
|
|
self.assertFalse(f.usesTime())
|
|
|
|
f = logging.Formatter('%(asctime)s')
|
|
|
|
self.assertTrue(f.usesTime())
|
2011-02-26 12:06:02 -04:00
|
|
|
f = logging.Formatter('%(asctime)-15s')
|
|
|
|
self.assertTrue(f.usesTime())
|
2018-10-15 15:41:36 -03:00
|
|
|
f = logging.Formatter('%(asctime)#15s')
|
|
|
|
self.assertTrue(f.usesTime())
|
2010-10-25 10:57:39 -03:00
|
|
|
|
|
|
|
def test_braces(self):
|
2010-12-27 07:18:52 -04:00
|
|
|
# Test {}-formatting
|
2010-10-25 10:57:39 -03:00
|
|
|
r = self.get_record()
|
|
|
|
f = logging.Formatter('$%{message}%$', style='{')
|
|
|
|
self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
|
|
|
|
f = logging.Formatter('{random}', style='{')
|
2018-10-15 15:41:36 -03:00
|
|
|
self.assertRaises(ValueError, f.format, r)
|
|
|
|
f = logging.Formatter("{message}", style='{')
|
2010-10-26 10:16:11 -03:00
|
|
|
self.assertFalse(f.usesTime())
|
|
|
|
f = logging.Formatter('{asctime}', style='{')
|
|
|
|
self.assertTrue(f.usesTime())
|
2011-02-26 12:06:02 -04:00
|
|
|
f = logging.Formatter('{asctime!s:15}', style='{')
|
|
|
|
self.assertTrue(f.usesTime())
|
|
|
|
f = logging.Formatter('{asctime:15}', style='{')
|
|
|
|
self.assertTrue(f.usesTime())
|
2010-10-25 10:57:39 -03:00
|
|
|
|
|
|
|
def test_dollars(self):
|
2010-12-27 07:18:52 -04:00
|
|
|
# Test $-formatting
|
2010-10-25 10:57:39 -03:00
|
|
|
r = self.get_record()
|
2018-10-15 15:41:36 -03:00
|
|
|
f = logging.Formatter('${message}', style='$')
|
|
|
|
self.assertEqual(f.format(r), 'Message with 2 placeholders')
|
2010-10-25 10:57:39 -03:00
|
|
|
f = logging.Formatter('$message', style='$')
|
|
|
|
self.assertEqual(f.format(r), 'Message with 2 placeholders')
|
|
|
|
f = logging.Formatter('$$%${message}%$$', style='$')
|
|
|
|
self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
|
|
|
|
f = logging.Formatter('${random}', style='$')
|
2018-10-15 15:41:36 -03:00
|
|
|
self.assertRaises(ValueError, f.format, r)
|
2010-10-26 10:16:11 -03:00
|
|
|
self.assertFalse(f.usesTime())
|
|
|
|
f = logging.Formatter('${asctime}', style='$')
|
|
|
|
self.assertTrue(f.usesTime())
|
|
|
|
f = logging.Formatter('$asctime', style='$')
|
|
|
|
self.assertTrue(f.usesTime())
|
2018-10-15 15:41:36 -03:00
|
|
|
f = logging.Formatter('${message}', style='$')
|
2010-10-26 10:16:11 -03:00
|
|
|
self.assertFalse(f.usesTime())
|
2018-10-15 15:41:36 -03:00
|
|
|
f = logging.Formatter('${asctime}--', style='$')
|
|
|
|
self.assertTrue(f.usesTime())
|
|
|
|
|
|
|
|
def test_format_validate(self):
|
|
|
|
# Check correct formatting
|
|
|
|
# Percentage style
|
|
|
|
f = logging.Formatter("%(levelname)-15s - %(message) 5s - %(process)03d - %(module) - %(asctime)*.3s")
|
|
|
|
self.assertEqual(f._fmt, "%(levelname)-15s - %(message) 5s - %(process)03d - %(module) - %(asctime)*.3s")
|
|
|
|
f = logging.Formatter("%(asctime)*s - %(asctime)*.3s - %(process)-34.33o")
|
|
|
|
self.assertEqual(f._fmt, "%(asctime)*s - %(asctime)*.3s - %(process)-34.33o")
|
|
|
|
f = logging.Formatter("%(process)#+027.23X")
|
|
|
|
self.assertEqual(f._fmt, "%(process)#+027.23X")
|
|
|
|
f = logging.Formatter("%(foo)#.*g")
|
|
|
|
self.assertEqual(f._fmt, "%(foo)#.*g")
|
|
|
|
|
|
|
|
# StrFormat Style
|
|
|
|
f = logging.Formatter("$%{message}%$ - {asctime!a:15} - {customfield['key']}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "$%{message}%$ - {asctime!a:15} - {customfield['key']}")
|
|
|
|
f = logging.Formatter("{process:.2f} - {custom.f:.4f}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{process:.2f} - {custom.f:.4f}")
|
|
|
|
f = logging.Formatter("{customfield!s:#<30}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{customfield!s:#<30}")
|
|
|
|
f = logging.Formatter("{message!r}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{message!r}")
|
|
|
|
f = logging.Formatter("{message!s}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{message!s}")
|
|
|
|
f = logging.Formatter("{message!a}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{message!a}")
|
|
|
|
f = logging.Formatter("{process!r:4.2}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{process!r:4.2}")
|
|
|
|
f = logging.Formatter("{process!s:<#30,.12f}- {custom:=+#30,.1d} - {module:^30}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{process!s:<#30,.12f}- {custom:=+#30,.1d} - {module:^30}")
|
|
|
|
f = logging.Formatter("{process!s:{w},.{p}}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{process!s:{w},.{p}}")
|
|
|
|
f = logging.Formatter("{foo:12.{p}}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{foo:12.{p}}")
|
|
|
|
f = logging.Formatter("{foo:{w}.6}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{foo:{w}.6}")
|
|
|
|
f = logging.Formatter("{foo[0].bar[1].baz}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{foo[0].bar[1].baz}")
|
|
|
|
f = logging.Formatter("{foo[k1].bar[k2].baz}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{foo[k1].bar[k2].baz}")
|
|
|
|
f = logging.Formatter("{12[k1].bar[k2].baz}", style="{")
|
|
|
|
self.assertEqual(f._fmt, "{12[k1].bar[k2].baz}")
|
|
|
|
|
|
|
|
# Dollar style
|
|
|
|
f = logging.Formatter("${asctime} - $message", style="$")
|
|
|
|
self.assertEqual(f._fmt, "${asctime} - $message")
|
|
|
|
f = logging.Formatter("$bar $$", style="$")
|
|
|
|
self.assertEqual(f._fmt, "$bar $$")
|
|
|
|
f = logging.Formatter("$bar $$$$", style="$")
|
|
|
|
self.assertEqual(f._fmt, "$bar $$$$") # this would print two $($$)
|
|
|
|
|
|
|
|
# Testing when ValueError being raised from incorrect format
|
|
|
|
# Percentage Style
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, "%(asctime)Z")
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, "%(asctime)b")
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, "%(asctime)*")
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, "%(asctime)*3s")
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, "%(asctime)_")
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{asctime}')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '${message}')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '%(foo)#12.3*f') # with both * and decimal number as precision
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '%(foo)0*.8*f')
|
|
|
|
|
|
|
|
# StrFormat Style
|
|
|
|
# Testing failure for '-' in field name
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
2020-09-25 15:08:50 -03:00
|
|
|
"invalid format: invalid field name/expression: 'name-thing'",
|
2018-10-15 15:41:36 -03:00
|
|
|
logging.Formatter, "{name-thing}", style="{"
|
|
|
|
)
|
|
|
|
# Testing failure for style mismatch
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: no fields",
|
|
|
|
logging.Formatter, '%(asctime)s', style='{'
|
|
|
|
)
|
|
|
|
# Testing failure for invalid conversion
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid conversion: 'Z'"
|
|
|
|
)
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{asctime!s:#30,15f}', style='{')
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: expected ':' after conversion specifier",
|
|
|
|
logging.Formatter, '{asctime!aa:15}', style='{'
|
|
|
|
)
|
|
|
|
# Testing failure for invalid spec
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
2020-09-25 15:08:50 -03:00
|
|
|
"invalid format: bad specifier: '.2ff'",
|
2018-10-15 15:41:36 -03:00
|
|
|
logging.Formatter, '{process:.2ff}', style='{'
|
|
|
|
)
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{process:.2Z}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{process!s:<##30,12g}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{process!s:<#30#,12g}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{process!s:{{w}},{{p}}}', style='{')
|
|
|
|
# Testing failure for mismatch braces
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
2020-09-25 15:08:50 -03:00
|
|
|
"invalid format: expected '}' before end of string",
|
2018-10-15 15:41:36 -03:00
|
|
|
logging.Formatter, '{process', style='{'
|
|
|
|
)
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
2020-09-25 15:08:50 -03:00
|
|
|
"invalid format: Single '}' encountered in format string",
|
2018-10-15 15:41:36 -03:00
|
|
|
logging.Formatter, 'process}', style='{'
|
|
|
|
)
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{{foo!r:4.2}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{{foo!r:4.2}}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo/bar}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo:{{w}}.{{p}}}}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo!X:{{w}}.{{p}}}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo!a:random}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo!a:ran{dom}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo!a:ran{d}om}', style='{')
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '{foo.!a:d}', style='{')
|
|
|
|
|
|
|
|
# Dollar style
|
|
|
|
# Testing failure for mismatch bare $
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: bare \'$\' not allowed",
|
|
|
|
logging.Formatter, '$bar $$$', style='$'
|
|
|
|
)
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: bare \'$\' not allowed",
|
|
|
|
logging.Formatter, 'bar $', style='$'
|
|
|
|
)
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: bare \'$\' not allowed",
|
|
|
|
logging.Formatter, 'foo $.', style='$'
|
|
|
|
)
|
|
|
|
# Testing failure for mismatch style
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: no fields",
|
|
|
|
logging.Formatter, '{asctime}', style='$'
|
|
|
|
)
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '%(asctime)s', style='$')
|
|
|
|
|
|
|
|
# Testing failure for incorrect fields
|
|
|
|
self.assert_error_message(
|
|
|
|
ValueError,
|
|
|
|
"invalid format: no fields",
|
|
|
|
logging.Formatter, 'foo', style='$'
|
|
|
|
)
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, '${asctime', style='$')
|
2010-10-25 10:57:39 -03:00
|
|
|
|
2020-06-18 11:18:58 -03:00
|
|
|
def test_defaults_parameter(self):
|
|
|
|
fmts = ['%(custom)s %(message)s', '{custom} {message}', '$custom $message']
|
|
|
|
styles = ['%', '{', '$']
|
|
|
|
for fmt, style in zip(fmts, styles):
|
|
|
|
f = logging.Formatter(fmt, style=style, defaults={'custom': 'Default'})
|
|
|
|
r = self.get_record()
|
|
|
|
self.assertEqual(f.format(r), 'Default Message with 2 placeholders')
|
|
|
|
r = self.get_record("custom")
|
|
|
|
self.assertEqual(f.format(r), '1234 Message with 2 placeholders')
|
|
|
|
|
|
|
|
# Without default
|
|
|
|
f = logging.Formatter(fmt, style=style)
|
|
|
|
r = self.get_record()
|
|
|
|
self.assertRaises(ValueError, f.format, r)
|
|
|
|
|
|
|
|
# Non-existing default is ignored
|
|
|
|
f = logging.Formatter(fmt, style=style, defaults={'Non-existing': 'Default'})
|
|
|
|
r = self.get_record("custom")
|
|
|
|
self.assertEqual(f.format(r), '1234 Message with 2 placeholders')
|
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
def test_invalid_style(self):
|
|
|
|
self.assertRaises(ValueError, logging.Formatter, None, None, 'x')
|
|
|
|
|
2011-04-27 04:30:30 -03:00
|
|
|
def test_time(self):
|
2011-04-26 14:43:05 -03:00
|
|
|
r = self.get_record()
|
2012-07-03 17:36:36 -03:00
|
|
|
dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 0, utc)
|
|
|
|
# We use None to indicate we want the local timezone
|
|
|
|
# We're essentially converting a UTC time to local time
|
|
|
|
r.created = time.mktime(dt.astimezone(None).timetuple())
|
2011-04-26 14:43:05 -03:00
|
|
|
r.msecs = 123
|
|
|
|
f = logging.Formatter('%(asctime)s %(message)s')
|
2011-04-26 16:26:41 -03:00
|
|
|
f.converter = time.gmtime
|
2011-04-26 14:43:05 -03:00
|
|
|
self.assertEqual(f.formatTime(r), '1993-04-21 08:03:00,123')
|
|
|
|
self.assertEqual(f.formatTime(r, '%Y:%d'), '1993:21')
|
2011-04-26 15:34:04 -03:00
|
|
|
f.format(r)
|
|
|
|
self.assertEqual(r.asctime, '1993-04-21 08:03:00,123')
|
|
|
|
|
2020-04-17 13:02:47 -03:00
|
|
|
def test_default_msec_format_none(self):
|
|
|
|
class NoMsecFormatter(logging.Formatter):
|
|
|
|
default_msec_format = None
|
|
|
|
default_time_format = '%d/%m/%Y %H:%M:%S'
|
|
|
|
|
|
|
|
r = self.get_record()
|
|
|
|
dt = datetime.datetime(1993, 4, 21, 8, 3, 0, 123, utc)
|
|
|
|
r.created = time.mktime(dt.astimezone(None).timetuple())
|
|
|
|
f = NoMsecFormatter()
|
|
|
|
f.converter = time.gmtime
|
|
|
|
self.assertEqual(f.formatTime(r), '21/04/1993 08:03:00')
|
|
|
|
|
2022-08-27 09:33:24 -03:00
|
|
|
def test_issue_89047(self):
|
|
|
|
f = logging.Formatter(fmt='{asctime}.{msecs:03.0f} {message}', style='{', datefmt="%Y-%m-%d %H:%M:%S")
|
|
|
|
for i in range(2500):
|
|
|
|
time.sleep(0.0004)
|
|
|
|
r = logging.makeLogRecord({'msg': 'Message %d' % (i + 1)})
|
|
|
|
s = f.format(r)
|
|
|
|
self.assertNotIn('.1000', s)
|
|
|
|
|
2020-04-17 13:02:47 -03:00
|
|
|
|
2011-04-26 15:34:04 -03:00
|
|
|
class TestBufferingFormatter(logging.BufferingFormatter):
|
|
|
|
def formatHeader(self, records):
|
|
|
|
return '[(%d)' % len(records)
|
|
|
|
|
|
|
|
def formatFooter(self, records):
|
|
|
|
return '(%d)]' % len(records)
|
|
|
|
|
|
|
|
class BufferingFormatterTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.records = [
|
|
|
|
logging.makeLogRecord({'msg': 'one'}),
|
|
|
|
logging.makeLogRecord({'msg': 'two'}),
|
|
|
|
]
|
|
|
|
|
|
|
|
def test_default(self):
|
|
|
|
f = logging.BufferingFormatter()
|
|
|
|
self.assertEqual('', f.format([]))
|
|
|
|
self.assertEqual('onetwo', f.format(self.records))
|
|
|
|
|
|
|
|
def test_custom(self):
|
|
|
|
f = TestBufferingFormatter()
|
|
|
|
self.assertEqual('[(2)onetwo(2)]', f.format(self.records))
|
|
|
|
lf = logging.Formatter('<%(message)s>')
|
|
|
|
f = TestBufferingFormatter(lf)
|
|
|
|
self.assertEqual('[(2)<one><two>(2)]', f.format(self.records))
|
2011-04-26 14:43:05 -03:00
|
|
|
|
|
|
|
class ExceptionTest(BaseTest):
|
|
|
|
def test_formatting(self):
|
|
|
|
r = self.root_logger
|
|
|
|
h = RecordingHandler()
|
|
|
|
r.addHandler(h)
|
|
|
|
try:
|
|
|
|
raise RuntimeError('deliberate mistake')
|
|
|
|
except:
|
|
|
|
logging.exception('failed', stack_info=True)
|
|
|
|
r.removeHandler(h)
|
|
|
|
h.close()
|
|
|
|
r = h.records[0]
|
|
|
|
self.assertTrue(r.exc_text.startswith('Traceback (most recent '
|
|
|
|
'call last):\n'))
|
|
|
|
self.assertTrue(r.exc_text.endswith('\nRuntimeError: '
|
|
|
|
'deliberate mistake'))
|
|
|
|
self.assertTrue(r.stack_info.startswith('Stack (most recent '
|
|
|
|
'call last):\n'))
|
|
|
|
self.assertTrue(r.stack_info.endswith('logging.exception(\'failed\', '
|
|
|
|
'stack_info=True)'))
|
|
|
|
|
|
|
|
|
2010-12-10 07:42:57 -04:00
|
|
|
class LastResortTest(BaseTest):
|
|
|
|
def test_last_resort(self):
|
2010-12-27 07:18:52 -04:00
|
|
|
# Test the last resort handler
|
2010-12-10 07:42:57 -04:00
|
|
|
root = self.root_logger
|
|
|
|
root.removeHandler(self.root_hdlr)
|
|
|
|
old_lastresort = logging.lastResort
|
|
|
|
old_raise_exceptions = logging.raiseExceptions
|
2014-05-31 04:19:12 -03:00
|
|
|
|
2010-12-10 07:42:57 -04:00
|
|
|
try:
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
root.debug('This should not appear')
|
|
|
|
self.assertEqual(stderr.getvalue(), '')
|
|
|
|
root.warning('Final chance!')
|
|
|
|
self.assertEqual(stderr.getvalue(), 'Final chance!\n')
|
|
|
|
|
|
|
|
# No handlers and no last resort, so 'No handlers' message
|
2010-12-10 07:42:57 -04:00
|
|
|
logging.lastResort = None
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
root.warning('Final chance!')
|
|
|
|
msg = 'No handlers could be found for logger "root"\n'
|
|
|
|
self.assertEqual(stderr.getvalue(), msg)
|
|
|
|
|
2010-12-10 07:42:57 -04:00
|
|
|
# 'No handlers' message only printed once
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
root.warning('Final chance!')
|
|
|
|
self.assertEqual(stderr.getvalue(), '')
|
|
|
|
|
|
|
|
# If raiseExceptions is False, no message is printed
|
2010-12-10 07:42:57 -04:00
|
|
|
root.manager.emittedNoHandlerWarning = False
|
|
|
|
logging.raiseExceptions = False
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stderr() as stderr:
|
|
|
|
root.warning('Final chance!')
|
|
|
|
self.assertEqual(stderr.getvalue(), '')
|
2010-12-10 07:42:57 -04:00
|
|
|
finally:
|
|
|
|
root.addHandler(self.root_hdlr)
|
|
|
|
logging.lastResort = old_lastresort
|
|
|
|
logging.raiseExceptions = old_raise_exceptions
|
|
|
|
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
class FakeHandler:
|
|
|
|
|
|
|
|
def __init__(self, identifier, called):
|
|
|
|
for method in ('acquire', 'flush', 'close', 'release'):
|
|
|
|
setattr(self, method, self.record_call(identifier, method, called))
|
|
|
|
|
|
|
|
def record_call(self, identifier, method_name, called):
|
|
|
|
def inner():
|
|
|
|
called.append('{} - {}'.format(identifier, method_name))
|
|
|
|
return inner
|
|
|
|
|
|
|
|
|
|
|
|
class RecordingHandler(logging.NullHandler):
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super(RecordingHandler, self).__init__(*args, **kwargs)
|
|
|
|
self.records = []
|
|
|
|
|
|
|
|
def handle(self, record):
|
|
|
|
"""Keep track of all the emitted records."""
|
|
|
|
self.records.append(record)
|
|
|
|
|
|
|
|
|
|
|
|
class ShutdownTest(BaseTest):
|
|
|
|
|
2011-04-20 11:41:14 -03:00
|
|
|
"""Test suite for the shutdown method."""
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(ShutdownTest, self).setUp()
|
|
|
|
self.called = []
|
|
|
|
|
|
|
|
raise_exceptions = logging.raiseExceptions
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(setattr, logging, 'raiseExceptions', raise_exceptions)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def raise_error(self, error):
|
|
|
|
def inner():
|
|
|
|
raise error()
|
|
|
|
return inner
|
|
|
|
|
|
|
|
def test_no_failure(self):
|
|
|
|
# create some fake handlers
|
|
|
|
handler0 = FakeHandler(0, self.called)
|
|
|
|
handler1 = FakeHandler(1, self.called)
|
|
|
|
handler2 = FakeHandler(2, self.called)
|
|
|
|
|
|
|
|
# create live weakref to those handlers
|
|
|
|
handlers = map(logging.weakref.ref, [handler0, handler1, handler2])
|
|
|
|
|
|
|
|
logging.shutdown(handlerList=list(handlers))
|
|
|
|
|
|
|
|
expected = ['2 - acquire', '2 - flush', '2 - close', '2 - release',
|
|
|
|
'1 - acquire', '1 - flush', '1 - close', '1 - release',
|
|
|
|
'0 - acquire', '0 - flush', '0 - close', '0 - release']
|
|
|
|
self.assertEqual(expected, self.called)
|
|
|
|
|
|
|
|
def _test_with_failure_in_method(self, method, error):
|
|
|
|
handler = FakeHandler(0, self.called)
|
|
|
|
setattr(handler, method, self.raise_error(error))
|
|
|
|
handlers = [logging.weakref.ref(handler)]
|
|
|
|
|
|
|
|
logging.shutdown(handlerList=list(handlers))
|
|
|
|
|
|
|
|
self.assertEqual('0 - release', self.called[-1])
|
|
|
|
|
|
|
|
def test_with_ioerror_in_acquire(self):
|
2012-12-25 10:47:37 -04:00
|
|
|
self._test_with_failure_in_method('acquire', OSError)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_with_ioerror_in_flush(self):
|
2012-12-25 10:47:37 -04:00
|
|
|
self._test_with_failure_in_method('flush', OSError)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_with_ioerror_in_close(self):
|
2012-12-25 10:47:37 -04:00
|
|
|
self._test_with_failure_in_method('close', OSError)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_with_valueerror_in_acquire(self):
|
|
|
|
self._test_with_failure_in_method('acquire', ValueError)
|
|
|
|
|
|
|
|
def test_with_valueerror_in_flush(self):
|
|
|
|
self._test_with_failure_in_method('flush', ValueError)
|
|
|
|
|
|
|
|
def test_with_valueerror_in_close(self):
|
|
|
|
self._test_with_failure_in_method('close', ValueError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_acquire_without_raise(self):
|
|
|
|
logging.raiseExceptions = False
|
|
|
|
self._test_with_failure_in_method('acquire', IndexError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_flush_without_raise(self):
|
|
|
|
logging.raiseExceptions = False
|
|
|
|
self._test_with_failure_in_method('flush', IndexError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_close_without_raise(self):
|
|
|
|
logging.raiseExceptions = False
|
|
|
|
self._test_with_failure_in_method('close', IndexError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_acquire_with_raise(self):
|
|
|
|
logging.raiseExceptions = True
|
|
|
|
self.assertRaises(IndexError, self._test_with_failure_in_method,
|
|
|
|
'acquire', IndexError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_flush_with_raise(self):
|
|
|
|
logging.raiseExceptions = True
|
|
|
|
self.assertRaises(IndexError, self._test_with_failure_in_method,
|
|
|
|
'flush', IndexError)
|
|
|
|
|
|
|
|
def test_with_other_error_in_close_with_raise(self):
|
|
|
|
logging.raiseExceptions = True
|
|
|
|
self.assertRaises(IndexError, self._test_with_failure_in_method,
|
|
|
|
'close', IndexError)
|
|
|
|
|
|
|
|
|
|
|
|
class ModuleLevelMiscTest(BaseTest):
|
|
|
|
|
2011-04-20 11:41:14 -03:00
|
|
|
"""Test suite for some module level methods."""
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_disable(self):
|
|
|
|
old_disable = logging.root.manager.disable
|
|
|
|
# confirm our assumptions are correct
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertEqual(old_disable, 0)
|
|
|
|
self.addCleanup(logging.disable, old_disable)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
logging.disable(83)
|
|
|
|
self.assertEqual(logging.root.manager.disable, 83)
|
|
|
|
|
2020-12-16 05:43:39 -04:00
|
|
|
self.assertRaises(ValueError, logging.disable, "doesnotexists")
|
|
|
|
|
|
|
|
class _NotAnIntOrString:
|
|
|
|
pass
|
|
|
|
|
|
|
|
self.assertRaises(TypeError, logging.disable, _NotAnIntOrString())
|
|
|
|
|
|
|
|
logging.disable("WARN")
|
|
|
|
|
2016-12-31 07:40:11 -04:00
|
|
|
# test the default value introduced in 3.7
|
|
|
|
# (Issue #28524)
|
|
|
|
logging.disable()
|
|
|
|
self.assertEqual(logging.root.manager.disable, logging.CRITICAL)
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def _test_log(self, method, level=None):
|
|
|
|
called = []
|
2014-05-31 04:19:12 -03:00
|
|
|
support.patch(self, logging, 'basicConfig',
|
|
|
|
lambda *a, **kw: called.append((a, kw)))
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
recording = RecordingHandler()
|
|
|
|
logging.root.addHandler(recording)
|
|
|
|
|
|
|
|
log_method = getattr(logging, method)
|
|
|
|
if level is not None:
|
|
|
|
log_method(level, "test me: %r", recording)
|
|
|
|
else:
|
|
|
|
log_method("test me: %r", recording)
|
|
|
|
|
|
|
|
self.assertEqual(len(recording.records), 1)
|
|
|
|
record = recording.records[0]
|
|
|
|
self.assertEqual(record.getMessage(), "test me: %r" % recording)
|
|
|
|
|
|
|
|
expected_level = level if level is not None else getattr(logging, method.upper())
|
|
|
|
self.assertEqual(record.levelno, expected_level)
|
|
|
|
|
|
|
|
# basicConfig was not called!
|
|
|
|
self.assertEqual(called, [])
|
|
|
|
|
|
|
|
def test_log(self):
|
|
|
|
self._test_log('log', logging.ERROR)
|
|
|
|
|
|
|
|
def test_debug(self):
|
|
|
|
self._test_log('debug')
|
|
|
|
|
|
|
|
def test_info(self):
|
|
|
|
self._test_log('info')
|
|
|
|
|
|
|
|
def test_warning(self):
|
|
|
|
self._test_log('warning')
|
|
|
|
|
|
|
|
def test_error(self):
|
|
|
|
self._test_log('error')
|
|
|
|
|
|
|
|
def test_critical(self):
|
|
|
|
self._test_log('critical')
|
|
|
|
|
|
|
|
def test_set_logger_class(self):
|
|
|
|
self.assertRaises(TypeError, logging.setLoggerClass, object)
|
|
|
|
|
|
|
|
class MyLogger(logging.Logger):
|
|
|
|
pass
|
|
|
|
|
|
|
|
logging.setLoggerClass(MyLogger)
|
|
|
|
self.assertEqual(logging.getLoggerClass(), MyLogger)
|
|
|
|
|
|
|
|
logging.setLoggerClass(logging.Logger)
|
|
|
|
self.assertEqual(logging.getLoggerClass(), logging.Logger)
|
|
|
|
|
2019-06-19 07:46:53 -03:00
|
|
|
def test_subclass_logger_cache(self):
|
|
|
|
# bpo-37258
|
|
|
|
message = []
|
|
|
|
|
|
|
|
class MyLogger(logging.getLoggerClass()):
|
|
|
|
def __init__(self, name='MyLogger', level=logging.NOTSET):
|
|
|
|
super().__init__(name, level)
|
|
|
|
message.append('initialized')
|
|
|
|
|
|
|
|
logging.setLoggerClass(MyLogger)
|
|
|
|
logger = logging.getLogger('just_some_logger')
|
|
|
|
self.assertEqual(message, ['initialized'])
|
|
|
|
stream = io.StringIO()
|
|
|
|
h = logging.StreamHandler(stream)
|
|
|
|
logger.addHandler(h)
|
|
|
|
try:
|
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
logger.debug("hello")
|
|
|
|
self.assertEqual(stream.getvalue().strip(), "hello")
|
|
|
|
|
|
|
|
stream.truncate(0)
|
|
|
|
stream.seek(0)
|
|
|
|
|
|
|
|
logger.setLevel(logging.INFO)
|
|
|
|
logger.debug("hello")
|
|
|
|
self.assertEqual(stream.getvalue(), "")
|
|
|
|
finally:
|
|
|
|
logger.removeHandler(h)
|
|
|
|
h.close()
|
|
|
|
logging.setLoggerClass(logging.Logger)
|
|
|
|
|
2013-12-21 10:51:54 -04:00
|
|
|
def test_logging_at_shutdown(self):
|
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 18:17:46 -04:00
|
|
|
# bpo-20037: Doing text I/O late at interpreter shutdown must not crash
|
|
|
|
code = textwrap.dedent("""
|
2013-12-21 10:51:54 -04:00
|
|
|
import logging
|
|
|
|
|
|
|
|
class A:
|
|
|
|
def __del__(self):
|
|
|
|
try:
|
|
|
|
raise ValueError("some error")
|
|
|
|
except Exception:
|
|
|
|
logging.exception("exception in __del__")
|
|
|
|
|
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 18:17:46 -04:00
|
|
|
a = A()
|
|
|
|
""")
|
2013-12-21 10:51:54 -04:00
|
|
|
rc, out, err = assert_python_ok("-c", code)
|
|
|
|
err = err.decode()
|
|
|
|
self.assertIn("exception in __del__", err)
|
|
|
|
self.assertIn("ValueError: some error", err)
|
|
|
|
|
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 18:17:46 -04:00
|
|
|
def test_logging_at_shutdown_open(self):
|
|
|
|
# bpo-26789: FileHandler keeps a reference to the builtin open()
|
|
|
|
# function to be able to open or reopen the file during Python
|
|
|
|
# finalization.
|
|
|
|
filename = os_helper.TESTFN
|
|
|
|
self.addCleanup(os_helper.unlink, filename)
|
|
|
|
|
|
|
|
code = textwrap.dedent(f"""
|
|
|
|
import builtins
|
|
|
|
import logging
|
|
|
|
|
|
|
|
class A:
|
|
|
|
def __del__(self):
|
|
|
|
logging.error("log in __del__")
|
|
|
|
|
|
|
|
# basicConfig() opens the file, but logging.shutdown() closes
|
|
|
|
# it at Python exit. When A.__del__() is called,
|
|
|
|
# FileHandler._open() must be called again to re-open the file.
|
2021-04-05 23:18:41 -03:00
|
|
|
logging.basicConfig(filename={filename!r}, encoding="utf-8")
|
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 18:17:46 -04:00
|
|
|
|
|
|
|
a = A()
|
|
|
|
|
|
|
|
# Simulate the Python finalization which removes the builtin
|
|
|
|
# open() function.
|
|
|
|
del builtins.open
|
|
|
|
""")
|
|
|
|
assert_python_ok("-c", code)
|
|
|
|
|
2021-04-05 23:18:41 -03:00
|
|
|
with open(filename, encoding="utf-8") as fp:
|
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 18:17:46 -04:00
|
|
|
self.assertEqual(fp.read().rstrip(), "ERROR:root:log in __del__")
|
|
|
|
|
2019-03-15 03:53:34 -03:00
|
|
|
def test_recursion_error(self):
|
|
|
|
# Issue 36272
|
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 18:17:46 -04:00
|
|
|
code = textwrap.dedent("""
|
2019-03-15 03:53:34 -03:00
|
|
|
import logging
|
|
|
|
|
|
|
|
def rec():
|
|
|
|
logging.error("foo")
|
|
|
|
rec()
|
|
|
|
|
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 18:17:46 -04:00
|
|
|
rec()
|
|
|
|
""")
|
2019-03-15 03:53:34 -03:00
|
|
|
rc, out, err = assert_python_failure("-c", code)
|
|
|
|
err = err.decode()
|
|
|
|
self.assertNotIn("Cannot recover from stack overflow.", err)
|
|
|
|
self.assertEqual(rc, 1)
|
|
|
|
|
2021-06-03 05:12:59 -03:00
|
|
|
def test_get_level_names_mapping(self):
|
|
|
|
mapping = logging.getLevelNamesMapping()
|
|
|
|
self.assertEqual(logging._nameToLevel, mapping) # value is equivalent
|
|
|
|
self.assertIsNot(logging._nameToLevel, mapping) # but not the internal data
|
|
|
|
new_mapping = logging.getLevelNamesMapping() # another call -> another copy
|
|
|
|
self.assertIsNot(mapping, new_mapping) # verify not the same object as before
|
|
|
|
self.assertEqual(mapping, new_mapping) # but equivalent in value
|
|
|
|
|
2013-12-21 10:51:54 -04:00
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
class LogRecordTest(BaseTest):
|
|
|
|
def test_str_rep(self):
|
|
|
|
r = logging.makeLogRecord({})
|
|
|
|
s = str(r)
|
|
|
|
self.assertTrue(s.startswith('<LogRecord: '))
|
|
|
|
self.assertTrue(s.endswith('>'))
|
|
|
|
|
|
|
|
def test_dict_arg(self):
|
|
|
|
h = RecordingHandler()
|
|
|
|
r = logging.getLogger()
|
|
|
|
r.addHandler(h)
|
|
|
|
d = {'less' : 'more' }
|
|
|
|
logging.warning('less is %(less)s', d)
|
|
|
|
self.assertIs(h.records[0].args, d)
|
|
|
|
self.assertEqual(h.records[0].message, 'less is more')
|
|
|
|
r.removeHandler(h)
|
|
|
|
h.close()
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2020-09-08 16:40:04 -03:00
|
|
|
@staticmethod # pickled as target of child process in the following test
|
|
|
|
def _extract_logrecord_process_name(key, logMultiprocessing, conn=None):
|
|
|
|
prev_logMultiprocessing = logging.logMultiprocessing
|
|
|
|
logging.logMultiprocessing = logMultiprocessing
|
2011-05-17 03:41:18 -03:00
|
|
|
try:
|
|
|
|
import multiprocessing as mp
|
2020-09-08 16:40:04 -03:00
|
|
|
name = mp.current_process().name
|
|
|
|
|
|
|
|
r1 = logging.makeLogRecord({'msg': f'msg1_{key}'})
|
2021-09-19 19:50:04 -03:00
|
|
|
|
|
|
|
# https://bugs.python.org/issue45128
|
|
|
|
with support.swap_item(sys.modules, 'multiprocessing', None):
|
|
|
|
r2 = logging.makeLogRecord({'msg': f'msg2_{key}'})
|
2020-09-08 16:40:04 -03:00
|
|
|
|
|
|
|
results = {'processName' : name,
|
|
|
|
'r1.processName': r1.processName,
|
|
|
|
'r2.processName': r2.processName,
|
|
|
|
}
|
|
|
|
finally:
|
|
|
|
logging.logMultiprocessing = prev_logMultiprocessing
|
|
|
|
if conn:
|
|
|
|
conn.send(results)
|
|
|
|
else:
|
|
|
|
return results
|
|
|
|
|
|
|
|
def test_multiprocessing(self):
|
2022-03-17 08:09:57 -03:00
|
|
|
support.skip_if_broken_multiprocessing_synchronize()
|
2020-09-08 16:40:04 -03:00
|
|
|
multiprocessing_imported = 'multiprocessing' in sys.modules
|
|
|
|
try:
|
|
|
|
# logMultiprocessing is True by default
|
|
|
|
self.assertEqual(logging.logMultiprocessing, True)
|
|
|
|
|
|
|
|
LOG_MULTI_PROCESSING = True
|
|
|
|
# When logMultiprocessing == True:
|
|
|
|
# In the main process processName = 'MainProcess'
|
2011-05-17 03:41:18 -03:00
|
|
|
r = logging.makeLogRecord({})
|
2020-09-08 16:40:04 -03:00
|
|
|
self.assertEqual(r.processName, 'MainProcess')
|
|
|
|
|
|
|
|
results = self._extract_logrecord_process_name(1, LOG_MULTI_PROCESSING)
|
|
|
|
self.assertEqual('MainProcess', results['processName'])
|
|
|
|
self.assertEqual('MainProcess', results['r1.processName'])
|
|
|
|
self.assertEqual('MainProcess', results['r2.processName'])
|
|
|
|
|
|
|
|
# In other processes, processName is correct when multiprocessing in imported,
|
|
|
|
# but it is (incorrectly) defaulted to 'MainProcess' otherwise (bpo-38762).
|
|
|
|
import multiprocessing
|
2023-02-03 19:20:46 -04:00
|
|
|
parent_conn, child_conn = multiprocessing.Pipe()
|
|
|
|
p = multiprocessing.Process(
|
2020-09-08 16:40:04 -03:00
|
|
|
target=self._extract_logrecord_process_name,
|
|
|
|
args=(2, LOG_MULTI_PROCESSING, child_conn,)
|
|
|
|
)
|
|
|
|
p.start()
|
|
|
|
results = parent_conn.recv()
|
|
|
|
self.assertNotEqual('MainProcess', results['processName'])
|
|
|
|
self.assertEqual(results['processName'], results['r1.processName'])
|
|
|
|
self.assertEqual('MainProcess', results['r2.processName'])
|
|
|
|
p.join()
|
|
|
|
|
|
|
|
finally:
|
|
|
|
if multiprocessing_imported:
|
|
|
|
import multiprocessing
|
|
|
|
|
2011-04-28 08:04:58 -03:00
|
|
|
def test_optional(self):
|
2022-05-26 05:30:51 -03:00
|
|
|
NONE = self.assertIsNone
|
2011-04-28 08:04:58 -03:00
|
|
|
NOT_NONE = self.assertIsNotNone
|
2022-05-26 05:30:51 -03:00
|
|
|
|
|
|
|
r = logging.makeLogRecord({})
|
2017-09-07 13:56:24 -03:00
|
|
|
NOT_NONE(r.thread)
|
|
|
|
NOT_NONE(r.threadName)
|
2011-04-28 08:04:58 -03:00
|
|
|
NOT_NONE(r.process)
|
|
|
|
NOT_NONE(r.processName)
|
2022-05-26 05:30:51 -03:00
|
|
|
NONE(r.taskName)
|
2011-04-28 08:04:58 -03:00
|
|
|
log_threads = logging.logThreads
|
|
|
|
log_processes = logging.logProcesses
|
|
|
|
log_multiprocessing = logging.logMultiprocessing
|
2022-05-26 05:30:51 -03:00
|
|
|
log_asyncio_tasks = logging.logAsyncioTasks
|
2011-04-28 08:04:58 -03:00
|
|
|
try:
|
|
|
|
logging.logThreads = False
|
|
|
|
logging.logProcesses = False
|
|
|
|
logging.logMultiprocessing = False
|
2022-05-26 05:30:51 -03:00
|
|
|
logging.logAsyncioTasks = False
|
2011-04-28 08:04:58 -03:00
|
|
|
r = logging.makeLogRecord({})
|
2022-05-26 05:30:51 -03:00
|
|
|
|
2011-04-28 08:04:58 -03:00
|
|
|
NONE(r.thread)
|
|
|
|
NONE(r.threadName)
|
|
|
|
NONE(r.process)
|
|
|
|
NONE(r.processName)
|
2022-05-26 05:30:51 -03:00
|
|
|
NONE(r.taskName)
|
2011-04-28 08:04:58 -03:00
|
|
|
finally:
|
|
|
|
logging.logThreads = log_threads
|
|
|
|
logging.logProcesses = log_processes
|
|
|
|
logging.logMultiprocessing = log_multiprocessing
|
2022-05-26 05:30:51 -03:00
|
|
|
logging.logAsyncioTasks = log_asyncio_tasks
|
|
|
|
|
|
|
|
async def _make_record_async(self, assertion):
|
|
|
|
r = logging.makeLogRecord({})
|
|
|
|
assertion(r.taskName)
|
|
|
|
|
2022-06-02 04:35:06 -03:00
|
|
|
@support.requires_working_socket()
|
2022-05-26 05:30:51 -03:00
|
|
|
def test_taskName_with_asyncio_imported(self):
|
|
|
|
try:
|
|
|
|
make_record = self._make_record_async
|
|
|
|
with asyncio.Runner() as runner:
|
|
|
|
logging.logAsyncioTasks = True
|
|
|
|
runner.run(make_record(self.assertIsNotNone))
|
|
|
|
logging.logAsyncioTasks = False
|
|
|
|
runner.run(make_record(self.assertIsNone))
|
|
|
|
finally:
|
|
|
|
asyncio.set_event_loop_policy(None)
|
|
|
|
|
2022-06-02 04:35:06 -03:00
|
|
|
@support.requires_working_socket()
|
2022-05-26 05:30:51 -03:00
|
|
|
def test_taskName_without_asyncio_imported(self):
|
|
|
|
try:
|
|
|
|
make_record = self._make_record_async
|
|
|
|
with asyncio.Runner() as runner, support.swap_item(sys.modules, 'asyncio', None):
|
|
|
|
logging.logAsyncioTasks = True
|
|
|
|
runner.run(make_record(self.assertIsNone))
|
|
|
|
logging.logAsyncioTasks = False
|
|
|
|
runner.run(make_record(self.assertIsNone))
|
|
|
|
finally:
|
|
|
|
asyncio.set_event_loop_policy(None)
|
|
|
|
|
2011-04-28 08:04:58 -03:00
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
class BasicConfigTest(unittest.TestCase):
|
|
|
|
|
2011-04-20 07:50:56 -03:00
|
|
|
"""Test suite for logging.basicConfig."""
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(BasicConfigTest, self).setUp()
|
2011-04-20 06:58:06 -03:00
|
|
|
self.handlers = logging.root.handlers
|
2011-04-20 07:50:56 -03:00
|
|
|
self.saved_handlers = logging._handlers.copy()
|
|
|
|
self.saved_handler_list = logging._handlerList[:]
|
2011-04-20 08:20:44 -03:00
|
|
|
self.original_logging_level = logging.root.level
|
2011-04-20 06:58:06 -03:00
|
|
|
self.addCleanup(self.cleanup)
|
2011-03-29 13:20:34 -03:00
|
|
|
logging.root.handlers = []
|
|
|
|
|
|
|
|
def tearDown(self):
|
2011-04-20 06:58:06 -03:00
|
|
|
for h in logging.root.handlers[:]:
|
|
|
|
logging.root.removeHandler(h)
|
|
|
|
h.close()
|
2011-03-29 13:20:34 -03:00
|
|
|
super(BasicConfigTest, self).tearDown()
|
|
|
|
|
2011-04-20 06:58:06 -03:00
|
|
|
def cleanup(self):
|
|
|
|
setattr(logging.root, 'handlers', self.handlers)
|
2011-04-20 07:50:56 -03:00
|
|
|
logging._handlers.clear()
|
|
|
|
logging._handlers.update(self.saved_handlers)
|
|
|
|
logging._handlerList[:] = self.saved_handler_list
|
2019-09-21 23:51:51 -03:00
|
|
|
logging.root.setLevel(self.original_logging_level)
|
2011-04-20 06:58:06 -03:00
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def test_no_kwargs(self):
|
|
|
|
logging.basicConfig()
|
|
|
|
|
|
|
|
# handler defaults to a StreamHandler to sys.stderr
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.StreamHandler)
|
|
|
|
self.assertEqual(handler.stream, sys.stderr)
|
|
|
|
|
|
|
|
formatter = handler.formatter
|
|
|
|
# format defaults to logging.BASIC_FORMAT
|
|
|
|
self.assertEqual(formatter._style._fmt, logging.BASIC_FORMAT)
|
|
|
|
# datefmt defaults to None
|
|
|
|
self.assertIsNone(formatter.datefmt)
|
|
|
|
# style defaults to %
|
|
|
|
self.assertIsInstance(formatter._style, logging.PercentStyle)
|
|
|
|
|
2011-11-11 14:39:25 -04:00
|
|
|
# level is not explicitly set
|
2011-04-20 08:50:42 -03:00
|
|
|
self.assertEqual(logging.root.level, self.original_logging_level)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2014-01-13 17:59:56 -04:00
|
|
|
def test_strformatstyle(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2014-01-13 17:59:56 -04:00
|
|
|
logging.basicConfig(stream=sys.stdout, style="{")
|
|
|
|
logging.error("Log an error")
|
|
|
|
sys.stdout.seek(0)
|
|
|
|
self.assertEqual(output.getvalue().strip(),
|
|
|
|
"ERROR:root:Log an error")
|
|
|
|
|
|
|
|
def test_stringtemplatestyle(self):
|
2014-05-31 04:19:12 -03:00
|
|
|
with support.captured_stdout() as output:
|
2014-01-13 17:59:56 -04:00
|
|
|
logging.basicConfig(stream=sys.stdout, style="$")
|
|
|
|
logging.error("Log an error")
|
|
|
|
sys.stdout.seek(0)
|
|
|
|
self.assertEqual(output.getvalue().strip(),
|
|
|
|
"ERROR:root:Log an error")
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def test_filename(self):
|
2013-03-08 05:50:57 -04:00
|
|
|
|
|
|
|
def cleanup(h1, h2, fn):
|
|
|
|
h1.close()
|
|
|
|
h2.close()
|
|
|
|
os.remove(fn)
|
|
|
|
|
2021-04-05 23:18:41 -03:00
|
|
|
logging.basicConfig(filename='test.log', encoding='utf-8')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
|
2021-04-05 23:18:41 -03:00
|
|
|
expected = logging.FileHandler('test.log', 'a', encoding='utf-8')
|
2011-03-29 13:20:34 -03:00
|
|
|
self.assertEqual(handler.stream.mode, expected.stream.mode)
|
|
|
|
self.assertEqual(handler.stream.name, expected.stream.name)
|
2013-03-08 05:50:57 -04:00
|
|
|
self.addCleanup(cleanup, handler, expected, 'test.log')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_filemode(self):
|
2013-03-08 05:50:57 -04:00
|
|
|
|
|
|
|
def cleanup(h1, h2, fn):
|
|
|
|
h1.close()
|
|
|
|
h2.close()
|
|
|
|
os.remove(fn)
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
logging.basicConfig(filename='test.log', filemode='wb')
|
|
|
|
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
expected = logging.FileHandler('test.log', 'wb')
|
|
|
|
self.assertEqual(handler.stream.mode, expected.stream.mode)
|
2013-03-08 05:50:57 -04:00
|
|
|
self.addCleanup(cleanup, handler, expected, 'test.log')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_stream(self):
|
|
|
|
stream = io.StringIO()
|
|
|
|
self.addCleanup(stream.close)
|
|
|
|
logging.basicConfig(stream=stream)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.StreamHandler)
|
|
|
|
self.assertEqual(handler.stream, stream)
|
|
|
|
|
|
|
|
def test_format(self):
|
2018-10-15 15:41:36 -03:00
|
|
|
logging.basicConfig(format='%(asctime)s - %(message)s')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
formatter = logging.root.handlers[0].formatter
|
2018-10-15 15:41:36 -03:00
|
|
|
self.assertEqual(formatter._style._fmt, '%(asctime)s - %(message)s')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_datefmt(self):
|
|
|
|
logging.basicConfig(datefmt='bar')
|
|
|
|
|
|
|
|
formatter = logging.root.handlers[0].formatter
|
|
|
|
self.assertEqual(formatter.datefmt, 'bar')
|
|
|
|
|
|
|
|
def test_style(self):
|
|
|
|
logging.basicConfig(style='$')
|
|
|
|
|
|
|
|
formatter = logging.root.handlers[0].formatter
|
|
|
|
self.assertIsInstance(formatter._style, logging.StringTemplateStyle)
|
|
|
|
|
|
|
|
def test_level(self):
|
|
|
|
old_level = logging.root.level
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(logging.root.setLevel, old_level)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
logging.basicConfig(level=57)
|
|
|
|
self.assertEqual(logging.root.level, 57)
|
2011-04-26 14:43:05 -03:00
|
|
|
# Test that second call has no effect
|
|
|
|
logging.basicConfig(level=58)
|
|
|
|
self.assertEqual(logging.root.level, 57)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2011-04-11 04:42:07 -03:00
|
|
|
def test_incompatible(self):
|
|
|
|
assertRaises = self.assertRaises
|
|
|
|
handlers = [logging.StreamHandler()]
|
|
|
|
stream = sys.stderr
|
|
|
|
assertRaises(ValueError, logging.basicConfig, filename='test.log',
|
2018-10-15 15:41:36 -03:00
|
|
|
stream=stream)
|
2011-04-11 04:42:07 -03:00
|
|
|
assertRaises(ValueError, logging.basicConfig, filename='test.log',
|
2018-10-15 15:41:36 -03:00
|
|
|
handlers=handlers)
|
2011-04-11 04:42:07 -03:00
|
|
|
assertRaises(ValueError, logging.basicConfig, stream=stream,
|
2018-10-15 15:41:36 -03:00
|
|
|
handlers=handlers)
|
2015-03-18 05:47:58 -03:00
|
|
|
# Issue 23207: test for invalid kwargs
|
|
|
|
assertRaises(ValueError, logging.basicConfig, loglevel=logging.INFO)
|
|
|
|
# Should pop both filename and filemode even if filename is None
|
|
|
|
logging.basicConfig(filename=None, filemode='a')
|
2011-04-11 04:42:07 -03:00
|
|
|
|
|
|
|
def test_handlers(self):
|
2011-04-26 14:43:05 -03:00
|
|
|
handlers = [
|
|
|
|
logging.StreamHandler(),
|
|
|
|
logging.StreamHandler(sys.stdout),
|
|
|
|
logging.StreamHandler(),
|
|
|
|
]
|
|
|
|
f = logging.Formatter()
|
|
|
|
handlers[2].setFormatter(f)
|
2011-04-11 04:42:07 -03:00
|
|
|
logging.basicConfig(handlers=handlers)
|
|
|
|
self.assertIs(handlers[0], logging.root.handlers[0])
|
|
|
|
self.assertIs(handlers[1], logging.root.handlers[1])
|
2011-04-26 14:43:05 -03:00
|
|
|
self.assertIs(handlers[2], logging.root.handlers[2])
|
2011-04-11 04:42:07 -03:00
|
|
|
self.assertIsNotNone(handlers[0].formatter)
|
|
|
|
self.assertIsNotNone(handlers[1].formatter)
|
2011-04-26 14:43:05 -03:00
|
|
|
self.assertIs(handlers[2].formatter, f)
|
2011-04-11 04:42:07 -03:00
|
|
|
self.assertIs(handlers[0].formatter, handlers[1].formatter)
|
|
|
|
|
2018-06-25 01:11:09 -03:00
|
|
|
def test_force(self):
|
|
|
|
old_string_io = io.StringIO()
|
|
|
|
new_string_io = io.StringIO()
|
|
|
|
old_handlers = [logging.StreamHandler(old_string_io)]
|
|
|
|
new_handlers = [logging.StreamHandler(new_string_io)]
|
|
|
|
logging.basicConfig(level=logging.WARNING, handlers=old_handlers)
|
|
|
|
logging.warning('warn')
|
|
|
|
logging.info('info')
|
|
|
|
logging.debug('debug')
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
logging.basicConfig(level=logging.INFO, handlers=new_handlers,
|
|
|
|
force=True)
|
|
|
|
logging.warning('warn')
|
|
|
|
logging.info('info')
|
|
|
|
logging.debug('debug')
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
self.assertEqual(old_string_io.getvalue().strip(),
|
|
|
|
'WARNING:root:warn')
|
|
|
|
self.assertEqual(new_string_io.getvalue().strip(),
|
|
|
|
'WARNING:root:warn\nINFO:root:info')
|
|
|
|
|
2019-06-17 13:40:52 -03:00
|
|
|
def test_encoding(self):
|
|
|
|
try:
|
|
|
|
encoding = 'utf-8'
|
|
|
|
logging.basicConfig(filename='test.log', encoding=encoding,
|
|
|
|
errors='strict',
|
|
|
|
format='%(message)s', level=logging.DEBUG)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
self.assertEqual(handler.encoding, encoding)
|
|
|
|
logging.debug('The Øresund Bridge joins Copenhagen to Malmö')
|
|
|
|
finally:
|
|
|
|
handler.close()
|
|
|
|
with open('test.log', encoding='utf-8') as f:
|
|
|
|
data = f.read().strip()
|
|
|
|
os.remove('test.log')
|
|
|
|
self.assertEqual(data,
|
|
|
|
'The Øresund Bridge joins Copenhagen to Malmö')
|
|
|
|
|
|
|
|
def test_encoding_errors(self):
|
|
|
|
try:
|
|
|
|
encoding = 'ascii'
|
|
|
|
logging.basicConfig(filename='test.log', encoding=encoding,
|
|
|
|
errors='ignore',
|
|
|
|
format='%(message)s', level=logging.DEBUG)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
self.assertEqual(handler.encoding, encoding)
|
|
|
|
logging.debug('The Øresund Bridge joins Copenhagen to Malmö')
|
|
|
|
finally:
|
|
|
|
handler.close()
|
|
|
|
with open('test.log', encoding='utf-8') as f:
|
|
|
|
data = f.read().strip()
|
|
|
|
os.remove('test.log')
|
|
|
|
self.assertEqual(data, 'The resund Bridge joins Copenhagen to Malm')
|
|
|
|
|
|
|
|
def test_encoding_errors_default(self):
|
|
|
|
try:
|
|
|
|
encoding = 'ascii'
|
|
|
|
logging.basicConfig(filename='test.log', encoding=encoding,
|
|
|
|
format='%(message)s', level=logging.DEBUG)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
self.assertEqual(handler.encoding, encoding)
|
|
|
|
self.assertEqual(handler.errors, 'backslashreplace')
|
|
|
|
logging.debug('😂: ☃️: The Øresund Bridge joins Copenhagen to Malmö')
|
|
|
|
finally:
|
|
|
|
handler.close()
|
|
|
|
with open('test.log', encoding='utf-8') as f:
|
|
|
|
data = f.read().strip()
|
|
|
|
os.remove('test.log')
|
|
|
|
self.assertEqual(data, r'\U0001f602: \u2603\ufe0f: The \xd8resund '
|
|
|
|
r'Bridge joins Copenhagen to Malm\xf6')
|
|
|
|
|
|
|
|
def test_encoding_errors_none(self):
|
|
|
|
# Specifying None should behave as 'strict'
|
|
|
|
try:
|
|
|
|
encoding = 'ascii'
|
|
|
|
logging.basicConfig(filename='test.log', encoding=encoding,
|
|
|
|
errors=None,
|
|
|
|
format='%(message)s', level=logging.DEBUG)
|
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
self.assertEqual(handler.encoding, encoding)
|
|
|
|
self.assertIsNone(handler.errors)
|
|
|
|
|
|
|
|
message = []
|
|
|
|
|
|
|
|
def dummy_handle_error(record):
|
2023-04-06 07:08:25 -03:00
|
|
|
message.append(str(sys.exception()))
|
2019-06-17 13:40:52 -03:00
|
|
|
|
|
|
|
handler.handleError = dummy_handle_error
|
|
|
|
logging.debug('The Øresund Bridge joins Copenhagen to Malmö')
|
|
|
|
self.assertTrue(message)
|
|
|
|
self.assertIn("'ascii' codec can't encode "
|
|
|
|
"character '\\xd8' in position 4:", message[0])
|
|
|
|
finally:
|
|
|
|
handler.close()
|
|
|
|
with open('test.log', encoding='utf-8') as f:
|
|
|
|
data = f.read().strip()
|
|
|
|
os.remove('test.log')
|
|
|
|
# didn't write anything due to the encoding error
|
|
|
|
self.assertEqual(data, r'')
|
|
|
|
|
2022-06-02 04:35:06 -03:00
|
|
|
@support.requires_working_socket()
|
2022-05-26 05:30:51 -03:00
|
|
|
def test_log_taskName(self):
|
|
|
|
async def log_record():
|
|
|
|
logging.warning('hello world')
|
|
|
|
|
2022-05-26 13:11:15 -03:00
|
|
|
handler = None
|
|
|
|
log_filename = make_temp_file('.log', 'test-logging-taskname-')
|
|
|
|
self.addCleanup(os.remove, log_filename)
|
2022-05-26 05:30:51 -03:00
|
|
|
try:
|
|
|
|
encoding = 'utf-8'
|
2022-05-26 13:11:15 -03:00
|
|
|
logging.basicConfig(filename=log_filename, errors='strict',
|
|
|
|
encoding=encoding, level=logging.WARNING,
|
|
|
|
format='%(taskName)s - %(message)s')
|
2022-05-26 05:30:51 -03:00
|
|
|
|
|
|
|
self.assertEqual(len(logging.root.handlers), 1)
|
|
|
|
handler = logging.root.handlers[0]
|
|
|
|
self.assertIsInstance(handler, logging.FileHandler)
|
|
|
|
|
|
|
|
with asyncio.Runner(debug=True) as runner:
|
|
|
|
logging.logAsyncioTasks = True
|
|
|
|
runner.run(log_record())
|
2022-05-26 13:11:15 -03:00
|
|
|
with open(log_filename, encoding='utf-8') as f:
|
2022-05-26 05:30:51 -03:00
|
|
|
data = f.read().strip()
|
|
|
|
self.assertRegex(data, r'Task-\d+ - hello world')
|
2022-05-26 13:11:15 -03:00
|
|
|
finally:
|
|
|
|
asyncio.set_event_loop_policy(None)
|
|
|
|
if handler:
|
|
|
|
handler.close()
|
2022-05-26 05:30:51 -03:00
|
|
|
|
2019-06-17 13:40:52 -03:00
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def _test_log(self, method, level=None):
|
|
|
|
# logging.root has no handlers so basicConfig should be called
|
|
|
|
called = []
|
|
|
|
|
|
|
|
old_basic_config = logging.basicConfig
|
|
|
|
def my_basic_config(*a, **kw):
|
|
|
|
old_basic_config()
|
|
|
|
old_level = logging.root.level
|
|
|
|
logging.root.setLevel(100) # avoid having messages in stderr
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(logging.root.setLevel, old_level)
|
2011-03-29 13:20:34 -03:00
|
|
|
called.append((a, kw))
|
|
|
|
|
2014-05-31 04:19:12 -03:00
|
|
|
support.patch(self, logging, 'basicConfig', my_basic_config)
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
log_method = getattr(logging, method)
|
|
|
|
if level is not None:
|
|
|
|
log_method(level, "test me")
|
|
|
|
else:
|
|
|
|
log_method("test me")
|
|
|
|
|
|
|
|
# basicConfig was called with no arguments
|
|
|
|
self.assertEqual(called, [((), {})])
|
|
|
|
|
|
|
|
def test_log(self):
|
|
|
|
self._test_log('log', logging.WARNING)
|
|
|
|
|
|
|
|
def test_debug(self):
|
|
|
|
self._test_log('debug')
|
|
|
|
|
|
|
|
def test_info(self):
|
|
|
|
self._test_log('info')
|
|
|
|
|
|
|
|
def test_warning(self):
|
|
|
|
self._test_log('warning')
|
|
|
|
|
|
|
|
def test_error(self):
|
|
|
|
self._test_log('error')
|
|
|
|
|
|
|
|
def test_critical(self):
|
|
|
|
self._test_log('critical')
|
|
|
|
|
|
|
|
|
|
|
|
class LoggerAdapterTest(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
super(LoggerAdapterTest, self).setUp()
|
|
|
|
old_handler_list = logging._handlerList[:]
|
|
|
|
|
|
|
|
self.recording = RecordingHandler()
|
|
|
|
self.logger = logging.root
|
|
|
|
self.logger.addHandler(self.recording)
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(self.logger.removeHandler, self.recording)
|
2011-03-29 13:20:34 -03:00
|
|
|
self.addCleanup(self.recording.close)
|
|
|
|
|
|
|
|
def cleanup():
|
|
|
|
logging._handlerList[:] = old_handler_list
|
|
|
|
|
|
|
|
self.addCleanup(cleanup)
|
|
|
|
self.addCleanup(logging.shutdown)
|
|
|
|
self.adapter = logging.LoggerAdapter(logger=self.logger, extra=None)
|
|
|
|
|
|
|
|
def test_exception(self):
|
|
|
|
msg = 'testing exception: %r'
|
|
|
|
exc = None
|
|
|
|
try:
|
2011-06-05 05:31:34 -03:00
|
|
|
1 / 0
|
|
|
|
except ZeroDivisionError as e:
|
2011-03-29 13:20:34 -03:00
|
|
|
exc = e
|
|
|
|
self.adapter.exception(msg, self.recording)
|
|
|
|
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertEqual(record.levelno, logging.ERROR)
|
|
|
|
self.assertEqual(record.msg, msg)
|
|
|
|
self.assertEqual(record.args, (self.recording,))
|
|
|
|
self.assertEqual(record.exc_info,
|
|
|
|
(exc.__class__, exc, exc.__traceback__))
|
|
|
|
|
2014-09-14 17:29:11 -03:00
|
|
|
def test_exception_excinfo(self):
|
|
|
|
try:
|
|
|
|
1 / 0
|
|
|
|
except ZeroDivisionError as e:
|
|
|
|
exc = e
|
|
|
|
|
|
|
|
self.adapter.exception('exc_info test', exc_info=exc)
|
|
|
|
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertEqual(record.exc_info,
|
|
|
|
(exc.__class__, exc, exc.__traceback__))
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def test_critical(self):
|
|
|
|
msg = 'critical test! %r'
|
|
|
|
self.adapter.critical(msg, self.recording)
|
|
|
|
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertEqual(record.levelno, logging.CRITICAL)
|
|
|
|
self.assertEqual(record.msg, msg)
|
|
|
|
self.assertEqual(record.args, (self.recording,))
|
2024-02-12 12:24:45 -04:00
|
|
|
self.assertEqual(record.funcName, 'test_critical')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_is_enabled_for(self):
|
|
|
|
old_disable = self.adapter.logger.manager.disable
|
|
|
|
self.adapter.logger.manager.disable = 33
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(setattr, self.adapter.logger.manager, 'disable',
|
|
|
|
old_disable)
|
2011-03-29 13:20:34 -03:00
|
|
|
self.assertFalse(self.adapter.isEnabledFor(32))
|
|
|
|
|
|
|
|
def test_has_handlers(self):
|
|
|
|
self.assertTrue(self.adapter.hasHandlers())
|
|
|
|
|
|
|
|
for handler in self.logger.handlers:
|
|
|
|
self.logger.removeHandler(handler)
|
|
|
|
|
2011-06-05 05:31:34 -03:00
|
|
|
self.assertFalse(self.logger.hasHandlers())
|
2011-03-29 13:20:34 -03:00
|
|
|
self.assertFalse(self.adapter.hasHandlers())
|
|
|
|
|
2017-09-14 12:34:47 -03:00
|
|
|
def test_nested(self):
|
|
|
|
msg = 'Adapters can be nested, yo.'
|
2024-02-12 12:24:45 -04:00
|
|
|
adapter = PrefixAdapter(logger=self.logger, extra=None)
|
|
|
|
adapter_adapter = PrefixAdapter(logger=adapter, extra=None)
|
2017-10-19 14:24:55 -03:00
|
|
|
adapter_adapter.prefix = 'AdapterAdapter'
|
|
|
|
self.assertEqual(repr(adapter), repr(adapter_adapter))
|
2017-09-14 12:34:47 -03:00
|
|
|
adapter_adapter.log(logging.CRITICAL, msg, self.recording)
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertEqual(record.levelno, logging.CRITICAL)
|
2017-10-19 14:24:55 -03:00
|
|
|
self.assertEqual(record.msg, f"Adapter AdapterAdapter {msg}")
|
2017-09-14 12:34:47 -03:00
|
|
|
self.assertEqual(record.args, (self.recording,))
|
2024-02-12 12:24:45 -04:00
|
|
|
self.assertEqual(record.funcName, 'test_nested')
|
2017-10-18 21:28:51 -03:00
|
|
|
orig_manager = adapter_adapter.manager
|
2017-10-19 14:24:55 -03:00
|
|
|
self.assertIs(adapter.manager, orig_manager)
|
2017-10-18 21:28:51 -03:00
|
|
|
self.assertIs(self.logger.manager, orig_manager)
|
|
|
|
temp_manager = object()
|
|
|
|
try:
|
|
|
|
adapter_adapter.manager = temp_manager
|
|
|
|
self.assertIs(adapter_adapter.manager, temp_manager)
|
2017-10-19 14:24:55 -03:00
|
|
|
self.assertIs(adapter.manager, temp_manager)
|
2017-10-18 21:28:51 -03:00
|
|
|
self.assertIs(self.logger.manager, temp_manager)
|
|
|
|
finally:
|
|
|
|
adapter_adapter.manager = orig_manager
|
|
|
|
self.assertIs(adapter_adapter.manager, orig_manager)
|
2017-10-19 14:24:55 -03:00
|
|
|
self.assertIs(adapter.manager, orig_manager)
|
2017-10-18 21:28:51 -03:00
|
|
|
self.assertIs(self.logger.manager, orig_manager)
|
2017-09-14 12:34:47 -03:00
|
|
|
|
2024-02-12 12:24:45 -04:00
|
|
|
def test_styled_adapter(self):
|
|
|
|
# Test an example from the Cookbook.
|
|
|
|
records = self.recording.records
|
|
|
|
adapter = StyleAdapter(self.logger)
|
|
|
|
adapter.warning('Hello, {}!', 'world')
|
|
|
|
self.assertEqual(str(records[-1].msg), 'Hello, world!')
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_styled_adapter')
|
|
|
|
adapter.log(logging.WARNING, 'Goodbye {}.', 'world')
|
|
|
|
self.assertEqual(str(records[-1].msg), 'Goodbye world.')
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_styled_adapter')
|
|
|
|
|
|
|
|
def test_nested_styled_adapter(self):
|
|
|
|
records = self.recording.records
|
|
|
|
adapter = PrefixAdapter(self.logger)
|
|
|
|
adapter.prefix = '{}'
|
|
|
|
adapter2 = StyleAdapter(adapter)
|
|
|
|
adapter2.warning('Hello, {}!', 'world')
|
|
|
|
self.assertEqual(str(records[-1].msg), '{} Hello, world!')
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_nested_styled_adapter')
|
|
|
|
adapter2.log(logging.WARNING, 'Goodbye {}.', 'world')
|
|
|
|
self.assertEqual(str(records[-1].msg), '{} Goodbye world.')
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_nested_styled_adapter')
|
|
|
|
|
|
|
|
def test_find_caller_with_stacklevel(self):
|
|
|
|
the_level = 1
|
|
|
|
trigger = self.adapter.warning
|
|
|
|
|
|
|
|
def innermost():
|
|
|
|
trigger('test', stacklevel=the_level)
|
|
|
|
|
|
|
|
def inner():
|
|
|
|
innermost()
|
|
|
|
|
|
|
|
def outer():
|
|
|
|
inner()
|
|
|
|
|
|
|
|
records = self.recording.records
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'innermost')
|
|
|
|
lineno = records[-1].lineno
|
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'inner')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
lineno = records[-1].lineno
|
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'outer')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
lineno = records[-1].lineno
|
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_find_caller_with_stacklevel')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
|
2023-08-15 04:23:54 -03:00
|
|
|
def test_extra_in_records(self):
|
|
|
|
self.adapter = logging.LoggerAdapter(logger=self.logger,
|
|
|
|
extra={'foo': '1'})
|
|
|
|
|
|
|
|
self.adapter.critical('foo should be here')
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertTrue(hasattr(record, 'foo'))
|
|
|
|
self.assertEqual(record.foo, '1')
|
|
|
|
|
|
|
|
def test_extra_not_merged_by_default(self):
|
|
|
|
self.adapter.critical('foo should NOT be here', extra={'foo': 'nope'})
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertFalse(hasattr(record, 'foo'))
|
|
|
|
|
|
|
|
def test_extra_merged(self):
|
|
|
|
self.adapter = logging.LoggerAdapter(logger=self.logger,
|
|
|
|
extra={'foo': '1'},
|
|
|
|
merge_extra=True)
|
|
|
|
|
|
|
|
self.adapter.critical('foo and bar should be here', extra={'bar': '2'})
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertTrue(hasattr(record, 'foo'))
|
|
|
|
self.assertTrue(hasattr(record, 'bar'))
|
|
|
|
self.assertEqual(record.foo, '1')
|
|
|
|
self.assertEqual(record.bar, '2')
|
|
|
|
|
|
|
|
def test_extra_merged_log_call_has_precedence(self):
|
|
|
|
self.adapter = logging.LoggerAdapter(logger=self.logger,
|
|
|
|
extra={'foo': '1'},
|
|
|
|
merge_extra=True)
|
|
|
|
|
|
|
|
self.adapter.critical('foo shall be min', extra={'foo': '2'})
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertTrue(hasattr(record, 'foo'))
|
|
|
|
self.assertEqual(record.foo, '2')
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2024-02-12 12:24:45 -04:00
|
|
|
class PrefixAdapter(logging.LoggerAdapter):
|
|
|
|
prefix = 'Adapter'
|
|
|
|
|
|
|
|
def process(self, msg, kwargs):
|
|
|
|
return f"{self.prefix} {msg}", kwargs
|
|
|
|
|
|
|
|
|
|
|
|
class Message:
|
|
|
|
def __init__(self, fmt, args):
|
|
|
|
self.fmt = fmt
|
|
|
|
self.args = args
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.fmt.format(*self.args)
|
|
|
|
|
|
|
|
|
|
|
|
class StyleAdapter(logging.LoggerAdapter):
|
|
|
|
def log(self, level, msg, /, *args, stacklevel=1, **kwargs):
|
|
|
|
if self.isEnabledFor(level):
|
|
|
|
msg, kwargs = self.process(msg, kwargs)
|
|
|
|
self.logger.log(level, Message(msg, args), **kwargs,
|
|
|
|
stacklevel=stacklevel+1)
|
|
|
|
|
|
|
|
|
2020-09-25 15:08:50 -03:00
|
|
|
class LoggerTest(BaseTest, AssertErrorMessage):
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
super(LoggerTest, self).setUp()
|
|
|
|
self.recording = RecordingHandler()
|
|
|
|
self.logger = logging.Logger(name='blah')
|
|
|
|
self.logger.addHandler(self.recording)
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(self.logger.removeHandler, self.recording)
|
2011-03-29 13:20:34 -03:00
|
|
|
self.addCleanup(self.recording.close)
|
|
|
|
self.addCleanup(logging.shutdown)
|
|
|
|
|
|
|
|
def test_set_invalid_level(self):
|
2020-09-25 15:08:50 -03:00
|
|
|
self.assert_error_message(
|
|
|
|
TypeError, 'Level not an integer or a valid string: None',
|
|
|
|
self.logger.setLevel, None)
|
|
|
|
self.assert_error_message(
|
|
|
|
TypeError, 'Level not an integer or a valid string: (0, 0)',
|
|
|
|
self.logger.setLevel, (0, 0))
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_exception(self):
|
|
|
|
msg = 'testing exception: %r'
|
|
|
|
exc = None
|
|
|
|
try:
|
2011-06-05 05:31:34 -03:00
|
|
|
1 / 0
|
|
|
|
except ZeroDivisionError as e:
|
2011-03-29 13:20:34 -03:00
|
|
|
exc = e
|
|
|
|
self.logger.exception(msg, self.recording)
|
|
|
|
|
|
|
|
self.assertEqual(len(self.recording.records), 1)
|
|
|
|
record = self.recording.records[0]
|
|
|
|
self.assertEqual(record.levelno, logging.ERROR)
|
|
|
|
self.assertEqual(record.msg, msg)
|
|
|
|
self.assertEqual(record.args, (self.recording,))
|
|
|
|
self.assertEqual(record.exc_info,
|
|
|
|
(exc.__class__, exc, exc.__traceback__))
|
|
|
|
|
|
|
|
def test_log_invalid_level_with_raise(self):
|
2015-07-21 16:40:18 -03:00
|
|
|
with support.swap_attr(logging, 'raiseExceptions', True):
|
2015-07-21 16:39:26 -03:00
|
|
|
self.assertRaises(TypeError, self.logger.log, '10', 'test message')
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_log_invalid_level_no_raise(self):
|
2015-07-21 16:40:18 -03:00
|
|
|
with support.swap_attr(logging, 'raiseExceptions', False):
|
2015-07-21 16:39:26 -03:00
|
|
|
self.logger.log('10', 'test message') # no exception happens
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
def test_find_caller_with_stack_info(self):
|
|
|
|
called = []
|
2014-05-31 04:19:12 -03:00
|
|
|
support.patch(self, logging.traceback, 'print_stack',
|
|
|
|
lambda f, file: called.append(file.getvalue()))
|
2011-03-29 13:20:34 -03:00
|
|
|
|
|
|
|
self.logger.findCaller(stack_info=True)
|
|
|
|
|
|
|
|
self.assertEqual(len(called), 1)
|
|
|
|
self.assertEqual('Stack (most recent call last):\n', called[0])
|
|
|
|
|
2018-06-05 13:24:18 -03:00
|
|
|
def test_find_caller_with_stacklevel(self):
|
|
|
|
the_level = 1
|
2022-03-27 10:49:28 -03:00
|
|
|
trigger = self.logger.warning
|
2018-06-05 13:24:18 -03:00
|
|
|
|
|
|
|
def innermost():
|
2022-03-27 10:49:28 -03:00
|
|
|
trigger('test', stacklevel=the_level)
|
2018-06-05 13:24:18 -03:00
|
|
|
|
|
|
|
def inner():
|
|
|
|
innermost()
|
|
|
|
|
|
|
|
def outer():
|
|
|
|
inner()
|
|
|
|
|
|
|
|
records = self.recording.records
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'innermost')
|
|
|
|
lineno = records[-1].lineno
|
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'inner')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
lineno = records[-1].lineno
|
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'outer')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
lineno = records[-1].lineno
|
2022-03-27 10:49:28 -03:00
|
|
|
root_logger = logging.getLogger()
|
|
|
|
root_logger.addHandler(self.recording)
|
|
|
|
trigger = logging.warning
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'outer')
|
|
|
|
root_logger.removeHandler(self.recording)
|
|
|
|
trigger = self.logger.warning
|
2018-06-05 13:24:18 -03:00
|
|
|
the_level += 1
|
|
|
|
outer()
|
|
|
|
self.assertEqual(records[-1].funcName, 'test_find_caller_with_stacklevel')
|
|
|
|
self.assertGreater(records[-1].lineno, lineno)
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
def test_make_record_with_extra_overwrite(self):
|
|
|
|
name = 'my record'
|
|
|
|
level = 13
|
|
|
|
fn = lno = msg = args = exc_info = func = sinfo = None
|
|
|
|
rv = logging._logRecordFactory(name, level, fn, lno, msg, args,
|
|
|
|
exc_info, func, sinfo)
|
|
|
|
|
|
|
|
for key in ('message', 'asctime') + tuple(rv.__dict__.keys()):
|
|
|
|
extra = {key: 'some value'}
|
|
|
|
self.assertRaises(KeyError, self.logger.makeRecord, name, level,
|
|
|
|
fn, lno, msg, args, exc_info,
|
|
|
|
extra=extra, sinfo=sinfo)
|
|
|
|
|
|
|
|
def test_make_record_with_extra_no_overwrite(self):
|
|
|
|
name = 'my record'
|
|
|
|
level = 13
|
|
|
|
fn = lno = msg = args = exc_info = func = sinfo = None
|
|
|
|
extra = {'valid_key': 'some value'}
|
|
|
|
result = self.logger.makeRecord(name, level, fn, lno, msg, args,
|
|
|
|
exc_info, extra=extra, sinfo=sinfo)
|
|
|
|
self.assertIn('valid_key', result.__dict__)
|
|
|
|
|
|
|
|
def test_has_handlers(self):
|
|
|
|
self.assertTrue(self.logger.hasHandlers())
|
|
|
|
|
|
|
|
for handler in self.logger.handlers:
|
|
|
|
self.logger.removeHandler(handler)
|
|
|
|
self.assertFalse(self.logger.hasHandlers())
|
|
|
|
|
|
|
|
def test_has_handlers_no_propagate(self):
|
|
|
|
child_logger = logging.getLogger('blah.child')
|
|
|
|
child_logger.propagate = False
|
|
|
|
self.assertFalse(child_logger.hasHandlers())
|
|
|
|
|
|
|
|
def test_is_enabled_for(self):
|
|
|
|
old_disable = self.logger.manager.disable
|
|
|
|
self.logger.manager.disable = 23
|
2011-06-05 05:31:34 -03:00
|
|
|
self.addCleanup(setattr, self.logger.manager, 'disable', old_disable)
|
2011-03-29 13:20:34 -03:00
|
|
|
self.assertFalse(self.logger.isEnabledFor(22))
|
|
|
|
|
2018-06-01 04:29:46 -03:00
|
|
|
def test_is_enabled_for_disabled_logger(self):
|
|
|
|
old_disabled = self.logger.disabled
|
|
|
|
old_disable = self.logger.manager.disable
|
|
|
|
|
|
|
|
self.logger.disabled = True
|
|
|
|
self.logger.manager.disable = 21
|
|
|
|
|
|
|
|
self.addCleanup(setattr, self.logger, 'disabled', old_disabled)
|
|
|
|
self.addCleanup(setattr, self.logger.manager, 'disable', old_disable)
|
|
|
|
|
|
|
|
self.assertFalse(self.logger.isEnabledFor(22))
|
|
|
|
|
2011-11-07 14:43:05 -04:00
|
|
|
def test_root_logger_aliases(self):
|
|
|
|
root = logging.getLogger()
|
|
|
|
self.assertIs(root, logging.root)
|
|
|
|
self.assertIs(root, logging.getLogger(None))
|
|
|
|
self.assertIs(root, logging.getLogger(''))
|
2019-08-02 12:53:00 -03:00
|
|
|
self.assertIs(root, logging.getLogger('root'))
|
2011-11-07 14:43:05 -04:00
|
|
|
self.assertIs(root, logging.getLogger('foo').root)
|
|
|
|
self.assertIs(root, logging.getLogger('foo.bar').root)
|
|
|
|
self.assertIs(root, logging.getLogger('foo').parent)
|
|
|
|
|
|
|
|
self.assertIsNot(root, logging.getLogger('\0'))
|
|
|
|
self.assertIsNot(root, logging.getLogger('foo.bar').parent)
|
|
|
|
|
|
|
|
def test_invalid_names(self):
|
|
|
|
self.assertRaises(TypeError, logging.getLogger, any)
|
|
|
|
self.assertRaises(TypeError, logging.getLogger, b'foo')
|
|
|
|
|
2017-06-06 12:34:29 -03:00
|
|
|
def test_pickling(self):
|
|
|
|
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
|
|
|
|
for name in ('', 'root', 'foo', 'foo.bar', 'baz.bar'):
|
|
|
|
logger = logging.getLogger(name)
|
|
|
|
s = pickle.dumps(logger, proto)
|
|
|
|
unpickled = pickle.loads(s)
|
|
|
|
self.assertIs(unpickled, logger)
|
|
|
|
|
2017-07-30 06:36:33 -03:00
|
|
|
def test_caching(self):
|
|
|
|
root = self.root_logger
|
|
|
|
logger1 = logging.getLogger("abc")
|
|
|
|
logger2 = logging.getLogger("abc.def")
|
|
|
|
|
|
|
|
# Set root logger level and ensure cache is empty
|
|
|
|
root.setLevel(logging.ERROR)
|
|
|
|
self.assertEqual(logger2.getEffectiveLevel(), logging.ERROR)
|
|
|
|
self.assertEqual(logger2._cache, {})
|
|
|
|
|
|
|
|
# Ensure cache is populated and calls are consistent
|
|
|
|
self.assertTrue(logger2.isEnabledFor(logging.ERROR))
|
|
|
|
self.assertFalse(logger2.isEnabledFor(logging.DEBUG))
|
|
|
|
self.assertEqual(logger2._cache, {logging.ERROR: True, logging.DEBUG: False})
|
|
|
|
self.assertEqual(root._cache, {})
|
|
|
|
self.assertTrue(logger2.isEnabledFor(logging.ERROR))
|
|
|
|
|
|
|
|
# Ensure root cache gets populated
|
|
|
|
self.assertEqual(root._cache, {})
|
|
|
|
self.assertTrue(root.isEnabledFor(logging.ERROR))
|
|
|
|
self.assertEqual(root._cache, {logging.ERROR: True})
|
|
|
|
|
|
|
|
# Set parent logger level and ensure caches are emptied
|
|
|
|
logger1.setLevel(logging.CRITICAL)
|
|
|
|
self.assertEqual(logger2.getEffectiveLevel(), logging.CRITICAL)
|
|
|
|
self.assertEqual(logger2._cache, {})
|
|
|
|
|
|
|
|
# Ensure logger2 uses parent logger's effective level
|
|
|
|
self.assertFalse(logger2.isEnabledFor(logging.ERROR))
|
|
|
|
|
|
|
|
# Set level to NOTSET and ensure caches are empty
|
|
|
|
logger2.setLevel(logging.NOTSET)
|
|
|
|
self.assertEqual(logger2.getEffectiveLevel(), logging.CRITICAL)
|
|
|
|
self.assertEqual(logger2._cache, {})
|
|
|
|
self.assertEqual(logger1._cache, {})
|
|
|
|
self.assertEqual(root._cache, {})
|
|
|
|
|
|
|
|
# Verify logger2 follows parent and not root
|
|
|
|
self.assertFalse(logger2.isEnabledFor(logging.ERROR))
|
|
|
|
self.assertTrue(logger2.isEnabledFor(logging.CRITICAL))
|
|
|
|
self.assertFalse(logger1.isEnabledFor(logging.ERROR))
|
|
|
|
self.assertTrue(logger1.isEnabledFor(logging.CRITICAL))
|
|
|
|
self.assertTrue(root.isEnabledFor(logging.ERROR))
|
|
|
|
|
|
|
|
# Disable logging in manager and ensure caches are clear
|
|
|
|
logging.disable()
|
|
|
|
self.assertEqual(logger2.getEffectiveLevel(), logging.CRITICAL)
|
|
|
|
self.assertEqual(logger2._cache, {})
|
|
|
|
self.assertEqual(logger1._cache, {})
|
|
|
|
self.assertEqual(root._cache, {})
|
|
|
|
|
|
|
|
# Ensure no loggers are enabled
|
|
|
|
self.assertFalse(logger1.isEnabledFor(logging.CRITICAL))
|
|
|
|
self.assertFalse(logger2.isEnabledFor(logging.CRITICAL))
|
|
|
|
self.assertFalse(root.isEnabledFor(logging.CRITICAL))
|
|
|
|
|
2011-03-29 13:20:34 -03:00
|
|
|
|
2010-09-17 15:57:36 -03:00
|
|
|
class BaseFileTest(BaseTest):
|
|
|
|
"Base class for handler tests that write log files"
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
BaseTest.setUp(self)
|
2022-05-26 13:11:15 -03:00
|
|
|
self.fn = make_temp_file(".log", "test_logging-2-")
|
2010-09-17 15:57:36 -03:00
|
|
|
self.rmfiles = []
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
for fn in self.rmfiles:
|
|
|
|
os.unlink(fn)
|
2010-12-27 07:18:52 -04:00
|
|
|
if os.path.exists(self.fn):
|
|
|
|
os.unlink(self.fn)
|
2010-09-18 00:54:32 -03:00
|
|
|
BaseTest.tearDown(self)
|
2010-09-17 15:57:36 -03:00
|
|
|
|
|
|
|
def assertLogFile(self, filename):
|
|
|
|
"Assert a log file is there and register it for deletion"
|
|
|
|
self.assertTrue(os.path.exists(filename),
|
2011-05-02 09:17:27 -03:00
|
|
|
msg="Log file %r does not exist" % filename)
|
2010-09-17 15:57:36 -03:00
|
|
|
self.rmfiles.append(filename)
|
|
|
|
|
2021-07-25 17:17:47 -03:00
|
|
|
def next_rec(self):
|
|
|
|
return logging.LogRecord('n', logging.DEBUG, 'p', 1,
|
|
|
|
self.next_message(), None, None, None)
|
2010-09-17 15:57:36 -03:00
|
|
|
|
2011-04-26 14:43:05 -03:00
|
|
|
class FileHandlerTest(BaseFileTest):
|
|
|
|
def test_delay(self):
|
|
|
|
os.unlink(self.fn)
|
2021-04-05 23:18:41 -03:00
|
|
|
fh = logging.FileHandler(self.fn, encoding='utf-8', delay=True)
|
2011-04-26 14:43:05 -03:00
|
|
|
self.assertIsNone(fh.stream)
|
|
|
|
self.assertFalse(os.path.exists(self.fn))
|
|
|
|
fh.handle(logging.makeLogRecord({}))
|
|
|
|
self.assertIsNotNone(fh.stream)
|
|
|
|
self.assertTrue(os.path.exists(self.fn))
|
|
|
|
fh.close()
|
|
|
|
|
2021-07-25 17:17:47 -03:00
|
|
|
def test_emit_after_closing_in_write_mode(self):
|
|
|
|
# Issue #42378
|
|
|
|
os.unlink(self.fn)
|
|
|
|
fh = logging.FileHandler(self.fn, encoding='utf-8', mode='w')
|
|
|
|
fh.setFormatter(logging.Formatter('%(message)s'))
|
|
|
|
fh.emit(self.next_rec()) # '1'
|
|
|
|
fh.close()
|
|
|
|
fh.emit(self.next_rec()) # '2'
|
|
|
|
with open(self.fn) as fp:
|
|
|
|
self.assertEqual(fp.read().strip(), '1')
|
2010-09-17 15:57:36 -03:00
|
|
|
|
2021-07-25 17:17:47 -03:00
|
|
|
class RotatingFileHandlerTest(BaseFileTest):
|
2022-05-19 07:43:16 -03:00
|
|
|
@unittest.skipIf(support.is_wasi, "WASI does not have /dev/null.")
|
2010-09-17 15:57:36 -03:00
|
|
|
def test_should_not_rollover(self):
|
|
|
|
# If maxbytes is zero rollover never occurs
|
2021-04-05 23:18:41 -03:00
|
|
|
rh = logging.handlers.RotatingFileHandler(
|
|
|
|
self.fn, encoding="utf-8", maxBytes=0)
|
2010-09-17 15:57:36 -03:00
|
|
|
self.assertFalse(rh.shouldRollover(None))
|
2010-10-30 06:50:18 -03:00
|
|
|
rh.close()
|
2021-10-10 12:15:24 -03:00
|
|
|
# bpo-45401 - test with special file
|
|
|
|
# We set maxBytes to 1 so that rollover would normally happen, except
|
|
|
|
# for the check for regular files
|
|
|
|
rh = logging.handlers.RotatingFileHandler(
|
|
|
|
os.devnull, encoding="utf-8", maxBytes=1)
|
|
|
|
self.assertFalse(rh.shouldRollover(self.next_rec()))
|
|
|
|
rh.close()
|
2010-09-17 15:57:36 -03:00
|
|
|
|
|
|
|
def test_should_rollover(self):
|
2021-04-05 23:18:41 -03:00
|
|
|
rh = logging.handlers.RotatingFileHandler(self.fn, encoding="utf-8", maxBytes=1)
|
2010-09-17 15:57:36 -03:00
|
|
|
self.assertTrue(rh.shouldRollover(self.next_rec()))
|
2010-10-30 06:50:18 -03:00
|
|
|
rh.close()
|
2010-09-17 15:57:36 -03:00
|
|
|
|
|
|
|
def test_file_created(self):
|
|
|
|
# checks that the file is created and assumes it was created
|
|
|
|
# by us
|
2021-04-05 23:18:41 -03:00
|
|
|
rh = logging.handlers.RotatingFileHandler(self.fn, encoding="utf-8")
|
2010-09-17 15:57:36 -03:00
|
|
|
rh.emit(self.next_rec())
|
|
|
|
self.assertLogFile(self.fn)
|
2010-10-30 06:50:18 -03:00
|
|
|
rh.close()
|
2010-09-17 15:57:36 -03:00
|
|
|
|
|
|
|
def test_rollover_filenames(self):
|
2012-01-04 08:02:26 -04:00
|
|
|
def namer(name):
|
|
|
|
return name + ".test"
|
2010-09-17 15:57:36 -03:00
|
|
|
rh = logging.handlers.RotatingFileHandler(
|
2021-04-05 23:18:41 -03:00
|
|
|
self.fn, encoding="utf-8", backupCount=2, maxBytes=1)
|
2012-01-04 08:02:26 -04:00
|
|
|
rh.namer = namer
|
2010-09-17 15:57:36 -03:00
|
|
|
rh.emit(self.next_rec())
|
|
|
|
self.assertLogFile(self.fn)
|
|
|
|
rh.emit(self.next_rec())
|
2012-01-04 08:02:26 -04:00
|
|
|
self.assertLogFile(namer(self.fn + ".1"))
|
2010-09-17 15:57:36 -03:00
|
|
|
rh.emit(self.next_rec())
|
2012-01-04 08:02:26 -04:00
|
|
|
self.assertLogFile(namer(self.fn + ".2"))
|
|
|
|
self.assertFalse(os.path.exists(namer(self.fn + ".3")))
|
|
|
|
rh.close()
|
|
|
|
|
2019-11-06 17:21:40 -04:00
|
|
|
def test_namer_rotator_inheritance(self):
|
|
|
|
class HandlerWithNamerAndRotator(logging.handlers.RotatingFileHandler):
|
|
|
|
def namer(self, name):
|
|
|
|
return name + ".test"
|
|
|
|
|
|
|
|
def rotator(self, source, dest):
|
|
|
|
if os.path.exists(source):
|
2021-04-28 10:47:10 -03:00
|
|
|
os.replace(source, dest + ".rotated")
|
2019-11-06 17:21:40 -04:00
|
|
|
|
|
|
|
rh = HandlerWithNamerAndRotator(
|
2021-04-05 23:18:41 -03:00
|
|
|
self.fn, encoding="utf-8", backupCount=2, maxBytes=1)
|
2019-11-06 17:21:40 -04:00
|
|
|
self.assertEqual(rh.namer(self.fn), self.fn + ".test")
|
|
|
|
rh.emit(self.next_rec())
|
|
|
|
self.assertLogFile(self.fn)
|
|
|
|
rh.emit(self.next_rec())
|
|
|
|
self.assertLogFile(rh.namer(self.fn + ".1") + ".rotated")
|
|
|
|
self.assertFalse(os.path.exists(rh.namer(self.fn + ".1")))
|
|
|
|
rh.close()
|
|
|
|
|
2020-05-18 19:02:57 -03:00
|
|
|
@support.requires_zlib()
|
2012-01-04 08:02:26 -04:00
|
|
|
def test_rotator(self):
|
|
|
|
def namer(name):
|
|
|
|
return name + ".gz"
|
|
|
|
|
|
|
|
def rotator(source, dest):
|
|
|
|
with open(source, "rb") as sf:
|
|
|
|
data = sf.read()
|
|
|
|
compressed = zlib.compress(data, 9)
|
|
|
|
with open(dest, "wb") as df:
|
|
|
|
df.write(compressed)
|
|
|
|
os.remove(source)
|
|
|
|
|
|
|
|
rh = logging.handlers.RotatingFileHandler(
|
2021-04-05 23:18:41 -03:00
|
|
|
self.fn, encoding="utf-8", backupCount=2, maxBytes=1)
|
2012-01-04 08:02:26 -04:00
|
|
|
rh.rotator = rotator
|
|
|
|
rh.namer = namer
|
|
|
|
m1 = self.next_rec()
|
|
|
|
rh.emit(m1)
|
|
|
|
self.assertLogFile(self.fn)
|
|
|
|
m2 = self.next_rec()
|
|
|
|
rh.emit(m2)
|
|
|
|
fn = namer(self.fn + ".1")
|
|
|
|
self.assertLogFile(fn)
|
2012-01-07 19:26:17 -04:00
|
|
|
newline = os.linesep
|
2012-01-04 08:02:26 -04:00
|
|
|
with open(fn, "rb") as f:
|
|
|
|
compressed = f.read()
|
|
|
|
data = zlib.decompress(compressed)
|
2012-01-07 19:26:17 -04:00
|
|
|
self.assertEqual(data.decode("ascii"), m1.msg + newline)
|
2012-01-04 08:02:26 -04:00
|
|
|
rh.emit(self.next_rec())
|
|
|
|
fn = namer(self.fn + ".2")
|
|
|
|
self.assertLogFile(fn)
|
|
|
|
with open(fn, "rb") as f:
|
|
|
|
compressed = f.read()
|
|
|
|
data = zlib.decompress(compressed)
|
2012-01-07 19:26:17 -04:00
|
|
|
self.assertEqual(data.decode("ascii"), m1.msg + newline)
|
2012-01-04 08:02:26 -04:00
|
|
|
rh.emit(self.next_rec())
|
|
|
|
fn = namer(self.fn + ".2")
|
|
|
|
with open(fn, "rb") as f:
|
|
|
|
compressed = f.read()
|
|
|
|
data = zlib.decompress(compressed)
|
2012-01-07 19:26:17 -04:00
|
|
|
self.assertEqual(data.decode("ascii"), m2.msg + newline)
|
2012-01-04 08:02:26 -04:00
|
|
|
self.assertFalse(os.path.exists(namer(self.fn + ".3")))
|
2010-10-30 06:50:18 -03:00
|
|
|
rh.close()
|
2010-09-17 15:57:36 -03:00
|
|
|
|
|
|
|
class TimedRotatingFileHandlerTest(BaseFileTest):
|
2022-05-19 07:43:16 -03:00
|
|
|
@unittest.skipIf(support.is_wasi, "WASI does not have /dev/null.")
|
2021-10-10 12:15:24 -03:00
|
|
|
def test_should_not_rollover(self):
|
|
|
|
# See bpo-45401. Should only ever rollover regular files
|
|
|
|
fh = logging.handlers.TimedRotatingFileHandler(
|
|
|
|
os.devnull, 'S', encoding="utf-8", backupCount=1)
|
|
|
|
time.sleep(1.1) # a little over a second ...
|
|
|
|
r = logging.makeLogRecord({'msg': 'testing - device file'})
|
|
|
|
self.assertFalse(fh.shouldRollover(r))
|
2021-10-11 05:54:44 -03:00
|
|
|
fh.close()
|
2021-10-10 12:15:24 -03:00
|
|
|
|
2011-05-02 09:17:27 -03:00
|
|
|
# other test methods added below
|
|
|
|
def test_rollover(self):
|
2021-04-28 23:34:56 -03:00
|
|
|
fh = logging.handlers.TimedRotatingFileHandler(
|
|
|
|
self.fn, 'S', encoding="utf-8", backupCount=1)
|
2012-03-05 05:43:47 -04:00
|
|
|
fmt = logging.Formatter('%(asctime)s %(message)s')
|
|
|
|
fh.setFormatter(fmt)
|
2012-03-05 08:45:51 -04:00
|
|
|
r1 = logging.makeLogRecord({'msg': 'testing - initial'})
|
|
|
|
fh.emit(r1)
|
2011-05-07 13:01:22 -03:00
|
|
|
self.assertLogFile(self.fn)
|
2012-03-05 08:45:51 -04:00
|
|
|
time.sleep(1.1) # a little over a second ...
|
2012-03-05 16:02:53 -04:00
|
|
|
r2 = logging.makeLogRecord({'msg': 'testing - after delay'})
|
2012-03-05 08:45:51 -04:00
|
|
|
fh.emit(r2)
|
2011-05-07 13:01:22 -03:00
|
|
|
fh.close()
|
|
|
|
# At this point, we should have a recent rotated file which we
|
|
|
|
# can test for the existence of. However, in practice, on some
|
|
|
|
# machines which run really slowly, we don't know how far back
|
2011-05-13 03:09:40 -03:00
|
|
|
# in time to go to look for the log file. So, we go back a fair
|
|
|
|
# bit, and stop as soon as we see a rotated file. In theory this
|
|
|
|
# could of course still fail, but the chances are lower.
|
2011-05-07 13:01:22 -03:00
|
|
|
found = False
|
|
|
|
now = datetime.datetime.now()
|
2011-05-13 12:41:57 -03:00
|
|
|
GO_BACK = 5 * 60 # seconds
|
2011-05-13 03:09:40 -03:00
|
|
|
for secs in range(GO_BACK):
|
|
|
|
prev = now - datetime.timedelta(seconds=secs)
|
2011-05-07 13:01:22 -03:00
|
|
|
fn = self.fn + prev.strftime(".%Y-%m-%d_%H-%M-%S")
|
|
|
|
found = os.path.exists(fn)
|
|
|
|
if found:
|
|
|
|
self.rmfiles.append(fn)
|
|
|
|
break
|
2011-05-13 03:09:40 -03:00
|
|
|
msg = 'No rotated files found, went back %d seconds' % GO_BACK
|
|
|
|
if not found:
|
2017-12-14 07:04:53 -04:00
|
|
|
# print additional diagnostics
|
2011-05-13 10:45:08 -03:00
|
|
|
dn, fn = os.path.split(self.fn)
|
|
|
|
files = [f for f in os.listdir(dn) if f.startswith(fn)]
|
2011-05-22 20:16:44 -03:00
|
|
|
print('Test time: %s' % now.strftime("%Y-%m-%d %H-%M-%S"), file=sys.stderr)
|
|
|
|
print('The only matching files are: %s' % files, file=sys.stderr)
|
2012-02-28 15:02:43 -04:00
|
|
|
for f in files:
|
|
|
|
print('Contents of %s:' % f)
|
2012-03-03 12:20:37 -04:00
|
|
|
path = os.path.join(dn, f)
|
|
|
|
with open(path, 'r') as tf:
|
2012-02-28 15:02:43 -04:00
|
|
|
print(tf.read())
|
2011-05-07 13:01:22 -03:00
|
|
|
self.assertTrue(found, msg=msg)
|
2010-09-17 15:57:36 -03:00
|
|
|
|
2011-05-05 08:59:14 -03:00
|
|
|
def test_invalid(self):
|
|
|
|
assertRaises = self.assertRaises
|
|
|
|
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, 'X', encoding="utf-8", delay=True)
|
2011-05-05 08:59:14 -03:00
|
|
|
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, 'W', encoding="utf-8", delay=True)
|
2011-05-05 08:59:14 -03:00
|
|
|
assertRaises(ValueError, logging.handlers.TimedRotatingFileHandler,
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, 'W7', encoding="utf-8", delay=True)
|
2011-05-05 08:59:14 -03:00
|
|
|
|
2013-04-12 13:04:23 -03:00
|
|
|
def test_compute_rollover_daily_attime(self):
|
|
|
|
currentTime = 0
|
|
|
|
atTime = datetime.time(12, 0, 0)
|
|
|
|
rh = logging.handlers.TimedRotatingFileHandler(
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, encoding="utf-8", when='MIDNIGHT', interval=1, backupCount=0,
|
|
|
|
utc=True, atTime=atTime)
|
2013-04-14 08:20:46 -03:00
|
|
|
try:
|
|
|
|
actual = rh.computeRollover(currentTime)
|
|
|
|
self.assertEqual(actual, currentTime + 12 * 60 * 60)
|
2013-04-12 13:04:23 -03:00
|
|
|
|
2013-04-14 08:20:46 -03:00
|
|
|
actual = rh.computeRollover(currentTime + 13 * 60 * 60)
|
|
|
|
self.assertEqual(actual, currentTime + 36 * 60 * 60)
|
|
|
|
finally:
|
|
|
|
rh.close()
|
2013-04-12 13:04:23 -03:00
|
|
|
|
2013-05-18 14:19:54 -03:00
|
|
|
#@unittest.skipIf(True, 'Temporarily skipped while failures investigated.')
|
2013-04-12 13:04:23 -03:00
|
|
|
def test_compute_rollover_weekly_attime(self):
|
2013-04-14 08:20:46 -03:00
|
|
|
currentTime = int(time.time())
|
|
|
|
today = currentTime - currentTime % 86400
|
|
|
|
|
2013-04-12 13:04:23 -03:00
|
|
|
atTime = datetime.time(12, 0, 0)
|
|
|
|
|
2013-05-18 14:19:54 -03:00
|
|
|
wday = time.gmtime(today).tm_wday
|
2013-04-12 13:04:23 -03:00
|
|
|
for day in range(7):
|
|
|
|
rh = logging.handlers.TimedRotatingFileHandler(
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, encoding="utf-8", when='W%d' % day, interval=1, backupCount=0,
|
|
|
|
utc=True, atTime=atTime)
|
2013-04-14 08:20:46 -03:00
|
|
|
try:
|
|
|
|
if wday > day:
|
|
|
|
# The rollover day has already passed this week, so we
|
|
|
|
# go over into next week
|
|
|
|
expected = (7 - wday + day)
|
|
|
|
else:
|
|
|
|
expected = (day - wday)
|
|
|
|
# At this point expected is in days from now, convert to seconds
|
|
|
|
expected *= 24 * 60 * 60
|
|
|
|
# Add in the rollover time
|
|
|
|
expected += 12 * 60 * 60
|
|
|
|
# Add in adjustment for today
|
|
|
|
expected += today
|
2013-04-15 07:59:35 -03:00
|
|
|
actual = rh.computeRollover(today)
|
|
|
|
if actual != expected:
|
|
|
|
print('failed in timezone: %d' % time.timezone)
|
2013-05-11 20:04:58 -03:00
|
|
|
print('local vars: %s' % locals())
|
2013-04-14 08:20:46 -03:00
|
|
|
self.assertEqual(actual, expected)
|
|
|
|
if day == wday:
|
|
|
|
# goes into following week
|
|
|
|
expected += 7 * 24 * 60 * 60
|
2013-04-14 08:25:25 -03:00
|
|
|
actual = rh.computeRollover(today + 13 * 60 * 60)
|
2013-04-15 07:59:35 -03:00
|
|
|
if actual != expected:
|
|
|
|
print('failed in timezone: %d' % time.timezone)
|
2013-05-11 20:04:58 -03:00
|
|
|
print('local vars: %s' % locals())
|
2013-04-14 08:20:46 -03:00
|
|
|
self.assertEqual(actual, expected)
|
|
|
|
finally:
|
|
|
|
rh.close()
|
2013-04-12 13:04:23 -03:00
|
|
|
|
2021-12-13 20:53:37 -04:00
|
|
|
def test_compute_files_to_delete(self):
|
|
|
|
# See bpo-46063 for background
|
|
|
|
wd = tempfile.mkdtemp(prefix='test_logging_')
|
|
|
|
self.addCleanup(shutil.rmtree, wd)
|
|
|
|
times = []
|
|
|
|
dt = datetime.datetime.now()
|
|
|
|
for i in range(10):
|
|
|
|
times.append(dt.strftime('%Y-%m-%d_%H-%M-%S'))
|
|
|
|
dt += datetime.timedelta(seconds=5)
|
|
|
|
prefixes = ('a.b', 'a.b.c', 'd.e', 'd.e.f')
|
|
|
|
files = []
|
|
|
|
rotators = []
|
|
|
|
for prefix in prefixes:
|
|
|
|
p = os.path.join(wd, '%s.log' % prefix)
|
|
|
|
rotator = logging.handlers.TimedRotatingFileHandler(p, when='s',
|
|
|
|
interval=5,
|
2021-12-14 12:46:07 -04:00
|
|
|
backupCount=7,
|
|
|
|
delay=True)
|
2021-12-13 20:53:37 -04:00
|
|
|
rotators.append(rotator)
|
|
|
|
if prefix.startswith('a.b'):
|
|
|
|
for t in times:
|
|
|
|
files.append('%s.log.%s' % (prefix, t))
|
|
|
|
else:
|
|
|
|
rotator.namer = lambda name: name.replace('.log', '') + '.log'
|
|
|
|
for t in times:
|
|
|
|
files.append('%s.%s.log' % (prefix, t))
|
|
|
|
# Create empty files
|
|
|
|
for fn in files:
|
|
|
|
p = os.path.join(wd, fn)
|
|
|
|
with open(p, 'wb') as f:
|
|
|
|
pass
|
|
|
|
# Now the checks that only the correct files are offered up for deletion
|
|
|
|
for i, prefix in enumerate(prefixes):
|
|
|
|
rotator = rotators[i]
|
|
|
|
candidates = rotator.getFilesToDelete()
|
|
|
|
self.assertEqual(len(candidates), 3)
|
|
|
|
if prefix.startswith('a.b'):
|
|
|
|
p = '%s.log.' % prefix
|
|
|
|
for c in candidates:
|
|
|
|
d, fn = os.path.split(c)
|
|
|
|
self.assertTrue(fn.startswith(p))
|
|
|
|
else:
|
|
|
|
for c in candidates:
|
|
|
|
d, fn = os.path.split(c)
|
|
|
|
self.assertTrue(fn.endswith('.log'))
|
|
|
|
self.assertTrue(fn.startswith(prefix + '.') and
|
|
|
|
fn[len(prefix) + 2].isdigit())
|
|
|
|
|
2013-04-12 13:04:23 -03:00
|
|
|
|
2010-09-17 15:57:36 -03:00
|
|
|
def secs(**kw):
|
|
|
|
return datetime.timedelta(**kw) // datetime.timedelta(seconds=1)
|
|
|
|
|
|
|
|
for when, exp in (('S', 1),
|
|
|
|
('M', 60),
|
|
|
|
('H', 60 * 60),
|
|
|
|
('D', 60 * 60 * 24),
|
2011-02-26 11:35:38 -04:00
|
|
|
('MIDNIGHT', 60 * 60 * 24),
|
2010-09-17 15:57:36 -03:00
|
|
|
# current time (epoch start) is a Thursday, W0 means Monday
|
2011-02-26 11:35:38 -04:00
|
|
|
('W0', secs(days=4, hours=24)),
|
|
|
|
):
|
2010-09-17 15:57:36 -03:00
|
|
|
def test_compute_rollover(self, when=when, exp=exp):
|
|
|
|
rh = logging.handlers.TimedRotatingFileHandler(
|
2021-04-28 23:34:56 -03:00
|
|
|
self.fn, encoding="utf-8", when=when, interval=1, backupCount=0, utc=True)
|
2011-02-26 11:35:38 -04:00
|
|
|
currentTime = 0.0
|
|
|
|
actual = rh.computeRollover(currentTime)
|
|
|
|
if exp != actual:
|
|
|
|
# Failures occur on some systems for MIDNIGHT and W0.
|
|
|
|
# Print detailed calculation for MIDNIGHT so we can try to see
|
|
|
|
# what's going on
|
|
|
|
if when == 'MIDNIGHT':
|
|
|
|
try:
|
|
|
|
if rh.utc:
|
|
|
|
t = time.gmtime(currentTime)
|
|
|
|
else:
|
|
|
|
t = time.localtime(currentTime)
|
|
|
|
currentHour = t[3]
|
|
|
|
currentMinute = t[4]
|
|
|
|
currentSecond = t[5]
|
|
|
|
# r is the number of seconds left between now and midnight
|
|
|
|
r = logging.handlers._MIDNIGHT - ((currentHour * 60 +
|
|
|
|
currentMinute) * 60 +
|
|
|
|
currentSecond)
|
|
|
|
result = currentTime + r
|
|
|
|
print('t: %s (%s)' % (t, rh.utc), file=sys.stderr)
|
|
|
|
print('currentHour: %s' % currentHour, file=sys.stderr)
|
|
|
|
print('currentMinute: %s' % currentMinute, file=sys.stderr)
|
|
|
|
print('currentSecond: %s' % currentSecond, file=sys.stderr)
|
|
|
|
print('r: %s' % r, file=sys.stderr)
|
|
|
|
print('result: %s' % result, file=sys.stderr)
|
2022-01-18 03:05:16 -04:00
|
|
|
except Exception as e:
|
|
|
|
print('exception in diagnostic code: %s' % e, file=sys.stderr)
|
2011-02-26 11:35:38 -04:00
|
|
|
self.assertEqual(exp, actual)
|
2010-10-30 06:50:18 -03:00
|
|
|
rh.close()
|
2010-09-17 15:57:36 -03:00
|
|
|
setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
|
|
|
|
|
2011-05-09 13:32:09 -03:00
|
|
|
|
2015-10-01 16:37:54 -03:00
|
|
|
@unittest.skipUnless(win32evtlog, 'win32evtlog/win32evtlogutil/pywintypes required for this test.')
|
2011-05-09 13:32:09 -03:00
|
|
|
class NTEventLogHandlerTest(BaseTest):
|
|
|
|
def test_basic(self):
|
|
|
|
logtype = 'Application'
|
|
|
|
elh = win32evtlog.OpenEventLog(None, logtype)
|
|
|
|
num_recs = win32evtlog.GetNumberOfEventLogRecords(elh)
|
2015-10-01 16:37:54 -03:00
|
|
|
|
|
|
|
try:
|
|
|
|
h = logging.handlers.NTEventLogHandler('test_logging')
|
|
|
|
except pywintypes.error as e:
|
2015-10-06 17:22:13 -03:00
|
|
|
if e.winerror == 5: # access denied
|
2015-10-01 16:37:54 -03:00
|
|
|
raise unittest.SkipTest('Insufficient privileges to run test')
|
2015-10-06 17:28:43 -03:00
|
|
|
raise
|
2015-10-01 16:37:54 -03:00
|
|
|
|
2011-05-09 13:32:09 -03:00
|
|
|
r = logging.makeLogRecord({'msg': 'Test Log Message'})
|
|
|
|
h.handle(r)
|
|
|
|
h.close()
|
|
|
|
# Now see if the event is recorded
|
2012-10-17 08:24:27 -03:00
|
|
|
self.assertLess(num_recs, win32evtlog.GetNumberOfEventLogRecords(elh))
|
2011-05-09 13:32:09 -03:00
|
|
|
flags = win32evtlog.EVENTLOG_BACKWARDS_READ | \
|
|
|
|
win32evtlog.EVENTLOG_SEQUENTIAL_READ
|
|
|
|
found = False
|
|
|
|
GO_BACK = 100
|
|
|
|
events = win32evtlog.ReadEventLog(elh, flags, GO_BACK)
|
|
|
|
for e in events:
|
|
|
|
if e.SourceName != 'test_logging':
|
|
|
|
continue
|
|
|
|
msg = win32evtlogutil.SafeFormatMessage(e, logtype)
|
|
|
|
if msg != 'Test Log Message\r\n':
|
|
|
|
continue
|
|
|
|
found = True
|
|
|
|
break
|
|
|
|
msg = 'Record not found in event log, went back %d records' % GO_BACK
|
|
|
|
self.assertTrue(found, msg=msg)
|
|
|
|
|
2016-09-07 21:37:03 -03:00
|
|
|
|
|
|
|
class MiscTestCase(unittest.TestCase):
|
|
|
|
def test__all__(self):
|
2020-08-17 02:20:40 -03:00
|
|
|
not_exported = {
|
|
|
|
'logThreads', 'logMultiprocessing', 'logProcesses', 'currentframe',
|
|
|
|
'PercentStyle', 'StrFormatStyle', 'StringTemplateStyle',
|
|
|
|
'Filterer', 'PlaceHolder', 'Manager', 'RootLogger', 'root',
|
2022-05-26 05:30:51 -03:00
|
|
|
'threading', 'logAsyncioTasks'}
|
2020-08-17 02:20:40 -03:00
|
|
|
support.check__all__(self, logging, not_exported=not_exported)
|
2016-09-07 21:37:03 -03:00
|
|
|
|
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
# Set the locale to the platform-dependent default. I have no idea
|
|
|
|
# why the test does this, but in any case we save the current locale
|
|
|
|
# first and restore it at the end.
|
2021-09-19 09:27:33 -03:00
|
|
|
def setUpModule():
|
2022-05-08 11:49:09 -03:00
|
|
|
unittest.enterModuleContext(support.run_with_locale('LC_ALL', ''))
|
2021-09-19 09:27:33 -03:00
|
|
|
|
2003-07-18 00:19:20 -03:00
|
|
|
|
Merged revisions 61189-61190,61192,61194-61195,61198-61199 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61189 | brett.cannon | 2008-03-03 01:38:58 +0100 (Mon, 03 Mar 2008) | 5 lines
Refactor test_logging to use unittest. This should finally solve the flakiness
issues.
Thanks to Antoine Pitrou for the patch.
........
r61190 | jeffrey.yasskin | 2008-03-03 02:27:03 +0100 (Mon, 03 Mar 2008) | 3 lines
compile.c always emits END_FINALLY after WITH_CLEANUP, so predict that in
ceval.c. This is worth about a .03-.04us speedup on a simple with block.
........
r61192 | brett.cannon | 2008-03-03 03:41:40 +0100 (Mon, 03 Mar 2008) | 4 lines
Move test_largefile over to using 'with' statements for open files.
Also rename the driver function to test_main() instead of main_test().
........
r61194 | brett.cannon | 2008-03-03 04:24:48 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61195 | brett.cannon | 2008-03-03 04:26:43 +0100 (Mon, 03 Mar 2008) | 3 lines
Add a note in the main test class' docstring that the order of execution of the
tests is important.
........
r61198 | brett.cannon | 2008-03-03 05:19:29 +0100 (Mon, 03 Mar 2008) | 4 lines
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
........
r61199 | neal.norwitz | 2008-03-03 05:37:45 +0100 (Mon, 03 Mar 2008) | 1 line
Only DECREF if ret != NULL
........
2008-03-03 15:15:45 -04:00
|
|
|
if __name__ == "__main__":
|
2021-09-19 09:27:33 -03:00
|
|
|
unittest.main()
|