mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00: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. ........
This commit is contained in:
parent
e5b4ca6c99
commit
ae5360b31e
13 changed files with 888 additions and 76 deletions
|
@ -587,6 +587,48 @@ class ConfigFileTest(BaseTest):
|
|||
# config5 specifies a custom handler class to be loaded
|
||||
config5 = config1.replace('class=StreamHandler', 'class=logging.StreamHandler')
|
||||
|
||||
# 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]
|
||||
class=FileHandler
|
||||
level=NOTSET
|
||||
formatter=form1
|
||||
args=('test.blah', 'a')
|
||||
|
||||
[formatter_form1]
|
||||
format=%(levelname)s ++ %(message)s
|
||||
datefmt=
|
||||
|
||||
[formatter_form2]
|
||||
format=%(message)s
|
||||
datefmt=
|
||||
"""
|
||||
|
||||
def apply_config(self, conf):
|
||||
try:
|
||||
fn = tempfile.mktemp(".ini")
|
||||
|
@ -653,6 +695,9 @@ class ConfigFileTest(BaseTest):
|
|||
def test_config5_ok(self):
|
||||
self.test_config1_ok(config=self.config5)
|
||||
|
||||
def test_config6_ok(self):
|
||||
self.test_config1_ok(config=self.config6)
|
||||
|
||||
class LogRecordStreamHandler(StreamRequestHandler):
|
||||
|
||||
"""Handler for a streaming logging request. It saves the log message in the
|
||||
|
@ -814,6 +859,31 @@ class MemoryTest(BaseTest):
|
|||
('foo', 'DEBUG', '3'),
|
||||
])
|
||||
|
||||
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")
|
||||
fn = tempfile.mktemp(".log")
|
||||
# the non-ascii data we write to the log.
|
||||
data = "foo\x80"
|
||||
try:
|
||||
handler = logging.FileHandler(fn, encoding="utf8")
|
||||
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
|
||||
f = open(fn, encoding="utf8")
|
||||
try:
|
||||
self.failUnlessEqual(f.read().rstrip(), data)
|
||||
finally:
|
||||
f.close()
|
||||
finally:
|
||||
if os.path.isfile(fn):
|
||||
os.remove(fn)
|
||||
|
||||
# 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
|
||||
|
@ -822,7 +892,8 @@ class MemoryTest(BaseTest):
|
|||
def test_main():
|
||||
run_unittest(BuiltinLevelsTest, BasicFilterTest,
|
||||
CustomLevelsAndFiltersTest, MemoryHandlerTest,
|
||||
ConfigFileTest, SocketHandlerTest, MemoryTest)
|
||||
ConfigFileTest, SocketHandlerTest, MemoryTest,
|
||||
EncodingTest)
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue