summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2015-10-01 19:37:54 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2015-10-01 19:37:54 (GMT)
commit223349cfb8a7a59caf7dffee55f21c800bdb947d (patch)
tree35bac100282d817d606337a8b32c51318877a423 /Lib
parentf223c53218fe76f333fce65f17fcaad5917d56d5 (diff)
downloadcpython-223349cfb8a7a59caf7dffee55f21c800bdb947d.zip
cpython-223349cfb8a7a59caf7dffee55f21c800bdb947d.tar.gz
cpython-223349cfb8a7a59caf7dffee55f21c800bdb947d.tar.bz2
Fixes #25097: Windows test is skipped if there are insufficient privileges, rather than failing.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_logging.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index ddab2e0..be3d02c 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -65,14 +65,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:
@@ -4098,13 +4094,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()