[Python-checkins] cpython (merge 3.4 -> 3.5): Fixes #25097: Merged fi from 3.4.

vinay.sajip python-checkins at python.org
Thu Oct 1 15:39:51 EDT 2015


https://hg.python.org/cpython/rev/b54528d8d8c3
changeset:   98466:b54528d8d8c3
branch:      3.5
parent:      98462:eaf9220bdee3
parent:      98465:72c57c120c19
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Thu Oct 01 20:38:53 2015 +0100
summary:
  Fixes #25097: Merged fi from 3.4.

files:
  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
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -58,14 +58,10 @@
 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 @@
     setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
 
 
- at unittest.skipUnless(win32evtlog, 'win32evtlog/win32evtlogutil required for this test.')
+ at 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()

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list