Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
22b25aa9
Commit
22b25aa9
authored
Jan 16, 2006
by
Vinay Sajip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for fileConfig. Contributed by Shane Hathaway.
parent
814fa0fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
1 deletion
+101
-1
Lib/test/test_logging.py
Lib/test/test_logging.py
+101
-1
No files found.
Lib/test/test_logging.py
View file @
22b25aa9
...
@@ -26,7 +26,7 @@ Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
...
@@ -26,7 +26,7 @@ Copyright (C) 2001-2002 Vinay Sajip. All Rights Reserved.
import
select
import
select
import
os
,
sys
,
string
,
struct
,
types
,
cPickle
,
cStringIO
import
os
,
sys
,
string
,
struct
,
types
,
cPickle
,
cStringIO
import
socket
,
threading
,
time
import
socket
,
t
empfile
,
t
hreading
,
time
import
logging
,
logging
.
handlers
,
logging
.
config
import
logging
,
logging
.
handlers
,
logging
.
config
BANNER
=
"-- %-10s %-6s ---------------------------------------------------
\
n
"
BANNER
=
"-- %-10s %-6s ---------------------------------------------------
\
n
"
...
@@ -392,6 +392,102 @@ def test3():
...
@@ -392,6 +392,102 @@ def test3():
doLog3
()
doLog3
()
hand
.
removeFilter
(
filt
)
hand
.
removeFilter
(
filt
)
#----------------------------------------------------------------------------
# Test 4
#----------------------------------------------------------------------------
# config0 is a standard configuratin.
config0
=
"""
[loggers]
keys=root
[handlers]
keys=hand1
[formatters]
keys=form1
[logger_root]
level=NOTSET
handlers=hand1
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[formatter_form1]
format=%(levelname)s:%(name)s:%(message)s
datefmt=
"""
# config1 adds a little to the standard configuration.
config1
=
"""
[loggers]
keys=root,parser
[handlers]
keys=hand1
[formatters]
keys=form1
[logger_root]
level=NOTSET
handlers=hand1
[logger_parser]
level=DEBUG
handlers=hand1
propagate=1
qualname=compiler.parser
[handler_hand1]
class=StreamHandler
level=NOTSET
formatter=form1
args=(sys.stdout,)
[formatter_form1]
format=%(levelname)s:%(name)s:%(message)s
datefmt=
"""
# config2 has a subtle configuration error that should be reported
config2
=
string
.
replace
(
config1
,
"sys.stdout"
,
"sys.stbout"
)
# config3 has a less subtle configuration error
config3
=
string
.
replace
(
config1
,
"formatter=form1"
,
"formatter=misspelled_name"
)
def
test4
():
for
i
in
range
(
4
):
conf
=
globals
()[
'config%d'
%
i
]
sys
.
stdout
.
write
(
'config%d: '
%
i
)
loggerDict
=
logging
.
getLogger
().
manager
.
loggerDict
saved_handlers
=
logging
.
_handlers
.
copy
()
saved_loggers
=
loggerDict
.
copy
()
try
:
fn
=
tempfile
.
mktemp
(
".ini"
)
f
=
open
(
fn
,
"w"
)
f
.
write
(
conf
)
f
.
close
()
try
:
logging
.
config
.
fileConfig
(
fn
)
except
:
t
=
sys
.
exc_info
()[
0
]
message
(
str
(
t
))
else
:
message
(
'ok.'
)
os
.
remove
(
fn
)
finally
:
logging
.
_handlers
.
clear
()
logging
.
_handlers
.
update
(
saved_handlers
)
loggerDict
=
logging
.
getLogger
().
manager
.
loggerDict
loggerDict
.
clear
()
loggerDict
.
update
(
saved_loggers
)
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Test Harness
# Test Harness
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
...
@@ -456,6 +552,10 @@ def test_main_inner():
...
@@ -456,6 +552,10 @@ def test_main_inner():
test3
()
test3
()
banner
(
"log_test3"
,
"end"
)
banner
(
"log_test3"
,
"end"
)
banner
(
"log_test4"
,
"begin"
)
test4
()
banner
(
"log_test4"
,
"end"
)
finally
:
finally
:
#wait for TCP receiver to terminate
#wait for TCP receiver to terminate
socketDataProcessed
.
wait
()
socketDataProcessed
.
wait
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment