diff options
| author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2015-10-01 19:39:30 (GMT) |
|---|---|---|
| committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2015-10-01 19:39:30 (GMT) |
| commit | 14b1b486ca96745485e4c6c71eefa56372e815d3 (patch) | |
| tree | 5f2b3b1eba8e9e3ce6a83c5fd0e4a94ca1ae4e0d /Lib/test/test_logging.py | |
| parent | 98f223dfa0440529261e921c8b9ec9a955c6d27f (diff) | |
| parent | d5963e615dc3a6c8a7cdc02095ad6d647a79fa8d (diff) | |
| download | cpython-14b1b486ca96745485e4c6c71eefa56372e815d3.zip cpython-14b1b486ca96745485e4c6c71eefa56372e815d3.tar.gz cpython-14b1b486ca96745485e4c6c71eefa56372e815d3.tar.bz2 | |
Fixes #25097: Merged fix from 3.5.
Diffstat (limited to 'Lib/test/test_logging.py')
| -rw-r--r-- | Lib/test/test_logging.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b6e64ce..041d38f 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -58,14 +58,10 @@ try: except ImportError: threading = None try: - import win32evtlog + import win32evtlog, win32evtlogutil, pywintypes except ImportError: - win32evtlog = None -try: - import win32evtlogutil -except ImportError: - win32evtlogutil = None - win32evtlog = None + win32evtlog = win32evtlogutil = pywintypes = None + try: import zlib except ImportError: @@ -4128,13 +4124,19 @@ for when, exp in (('S', 1), 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): def test_basic(self): logtype = 'Application' elh = win32evtlog.OpenEventLog(None, logtype) 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'}) h.handle(r) h.close() |
