mirror of https://github.com/python/cpython
Fixes #25097: Merged fi from 3.4.
This commit is contained in:
commit
d5963e615d
|
@ -58,14 +58,10 @@ try:
|
||||||
except ImportError:
|
except ImportError:
|
||||||
threading = None
|
threading = None
|
||||||
try:
|
try:
|
||||||
import win32evtlog
|
import win32evtlog, win32evtlogutil, pywintypes
|
||||||
except ImportError:
|
except ImportError:
|
||||||
win32evtlog = None
|
win32evtlog = win32evtlogutil = pywintypes = None
|
||||||
try:
|
|
||||||
import win32evtlogutil
|
|
||||||
except ImportError:
|
|
||||||
win32evtlogutil = None
|
|
||||||
win32evtlog = None
|
|
||||||
try:
|
try:
|
||||||
import zlib
|
import zlib
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -4128,13 +4124,19 @@ for when, exp in (('S', 1),
|
||||||
setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
|
setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(win32evtlog, 'win32evtlog/win32evtlogutil required for this test.')
|
@unittest.skipUnless(win32evtlog, 'win32evtlog/win32evtlogutil/pywintypes required for this test.')
|
||||||
class NTEventLogHandlerTest(BaseTest):
|
class NTEventLogHandlerTest(BaseTest):
|
||||||
def test_basic(self):
|
def test_basic(self):
|
||||||
logtype = 'Application'
|
logtype = 'Application'
|
||||||
elh = win32evtlog.OpenEventLog(None, logtype)
|
elh = win32evtlog.OpenEventLog(None, logtype)
|
||||||
num_recs = win32evtlog.GetNumberOfEventLogRecords(elh)
|
num_recs = win32evtlog.GetNumberOfEventLogRecords(elh)
|
||||||
h = logging.handlers.NTEventLogHandler('test_logging')
|
|
||||||
|
try:
|
||||||
|
h = logging.handlers.NTEventLogHandler('test_logging')
|
||||||
|
except pywintypes.error as e:
|
||||||
|
if e[0] == 5: # access denied
|
||||||
|
raise unittest.SkipTest('Insufficient privileges to run test')
|
||||||
|
|
||||||
r = logging.makeLogRecord({'msg': 'Test Log Message'})
|
r = logging.makeLogRecord({'msg': 'Test Log Message'})
|
||||||
h.handle(r)
|
h.handle(r)
|
||||||
h.close()
|
h.close()
|
||||||
|
|
Loading…
Reference in New Issue