Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
60ccd821
Kaydet (Commit)
60ccd821
authored
May 09, 2011
tarafından
Vinay Sajip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improved Windows test coverage.
üst
5fffaab1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
1 deletion
+39
-1
test_logging.py
Lib/test/test_logging.py
+39
-1
No files found.
Lib/test/test_logging.py
Dosyayı görüntüle @
60ccd821
...
...
@@ -58,6 +58,15 @@ try:
import
threading
except
ImportError
:
threading
=
None
try
:
import
win32evtlog
except
ImportError
:
win32evtlog
=
None
try
:
import
win32evtlogutil
except
ImportError
:
win32evtlogutil
=
None
win32evtlog
=
None
class
BaseTest
(
unittest
.
TestCase
):
...
...
@@ -3565,6 +3574,35 @@ for when, exp in (('S', 1),
rh
.
close
()
setattr
(
TimedRotatingFileHandlerTest
,
"test_compute_rollover_
%
s"
%
when
,
test_compute_rollover
)
@unittest.skipUnless
(
win32evtlog
,
'win32evtlog/win32evtlogutil required for this test.'
)
class
NTEventLogHandlerTest
(
BaseTest
):
def
test_basic
(
self
):
logtype
=
'Application'
elh
=
win32evtlog
.
OpenEventLog
(
None
,
logtype
)
num_recs
=
win32evtlog
.
GetNumberOfEventLogRecords
(
elh
)
h
=
logging
.
handlers
.
NTEventLogHandler
(
'test_logging'
)
r
=
logging
.
makeLogRecord
({
'msg'
:
'Test Log Message'
})
h
.
handle
(
r
)
h
.
close
()
# Now see if the event is recorded
self
.
assertTrue
(
num_recs
<
win32evtlog
.
GetNumberOfEventLogRecords
(
elh
))
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
)
# 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.
...
...
@@ -3580,7 +3618,7 @@ def test_main():
BasicConfigTest
,
LoggerAdapterTest
,
LoggerTest
,
SMTPHandlerTest
,
FileHandlerTest
,
RotatingFileHandlerTest
,
LastResortTest
,
LogRecordTest
,
ExceptionTest
,
SysLogHandlerTest
,
HTTPHandlerTest
,
SysLogHandlerTest
,
HTTPHandlerTest
,
NTEventLogHandlerTest
,
TimedRotatingFileHandlerTest
)
...
...
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