[pywin32-checkins] pywin32/win32/Lib pywin32_testutil.py,1.2,1.3
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2009-02-16 06:27:26
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv21125/win32/Lib Modified Files: pywin32_testutil.py Log Message: Fix is_admin() and more verbose reporting of skipped tests Index: pywin32_testutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywin32_testutil.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** pywin32_testutil.py 25 Jan 2009 03:12:18 -0000 1.2 --- pywin32_testutil.py 16 Feb 2009 06:27:22 -0000 1.3 *************** *** 177,183 **** if _is_admin is None: from win32com.shell.shell import IsUserAnAdmin try: _is_admin = IsUserAnAdmin() ! except NotImplementedError: # not impl on this platform - must be old - assume is admin _is_admin = True --- 177,186 ---- if _is_admin is None: from win32com.shell.shell import IsUserAnAdmin + import pythoncom try: _is_admin = IsUserAnAdmin() ! except pythoncom.com_error, exc: ! if exc.hresult != winerror.E_NOTIMPL: ! raise # not impl on this platform - must be old - assume is admin _is_admin = True *************** *** 195,199 **** def __init__(self, *args, **kw): super(TestResult, self).__init__(*args, **kw) ! self.num_skipped = 0 def addError(self, test, err): --- 198,202 ---- def __init__(self, *args, **kw): super(TestResult, self).__init__(*args, **kw) ! self.skips = {} # count of skips for each reason. def addError(self, test, err): *************** *** 222,228 **** if isinstance(exc_val, TestSkipped): ! self.num_skipped += 1 if self.showAll: ! self.stream.writeln("SKIP") elif self.dots: self.stream.write('S') --- 225,238 ---- if isinstance(exc_val, TestSkipped): ! reason = exc_val.args[0] ! # if the reason itself is another exception, get its args. ! try: ! reason = tuple(reason.args) ! except (AttributeError, TypeError): ! pass ! self.skips.setdefault(reason, 0) ! self.skips[reason] += 1 if self.showAll: ! self.stream.writeln("SKIP (%s)" % (reason,)) elif self.dots: self.stream.write('S') *************** *** 233,238 **** def printErrors(self): super(TestResult, self).printErrors() ! if self.num_skipped: ! self.stream.writeln("SKIPPED: %d tests" % self.num_skipped) # TestRunner subclass necessary just to get our TestResult hooked up. --- 243,248 ---- def printErrors(self): super(TestResult, self).printErrors() ! for reason, num_skipped in self.skips.iteritems(): ! self.stream.writeln("SKIPPED: %d tests - %s" % (num_skipped, reason)) # TestRunner subclass necessary just to get our TestResult hooked up. |