BF(OSX): apparently exceptions could not be compared for identity, use repr

pull/1004/head
Yaroslav Halchenko 2015-03-25 11:27:22 -04:00
parent d28880fdca
commit eb05cd7bd5
1 changed files with 13 additions and 5 deletions

View File

@ -71,19 +71,24 @@ class TransmitterBase(unittest.TestCase):
"""Call after every test case.""" """Call after every test case."""
self.server.quit() self.server.quit()
def setGetTest(self, cmd, inValue, outValue=None, outCode=0, jail=None): def setGetTest(self, cmd, inValue, outValue=None, outCode=0, jail=None, repr_=False):
setCmd = ["set", cmd, inValue] setCmd = ["set", cmd, inValue]
getCmd = ["get", cmd] getCmd = ["get", cmd]
if jail is not None: if jail is not None:
setCmd.insert(1, jail) setCmd.insert(1, jail)
getCmd.insert(1, jail) getCmd.insert(1, jail)
if outValue is None: if outValue is None:
outValue = inValue outValue = inValue
self.assertEqual(self.transm.proceed(setCmd), (outCode, outValue)) def v(x):
"""Prepare value for comparison"""
return (repr(x) if repr_ else x)
self.assertEqual(v(self.transm.proceed(setCmd)), v((outCode, outValue)))
if not outCode: if not outCode:
# if we expected to get it set without problem, check new value # if we expected to get it set without problem, check new value
self.assertEqual(self.transm.proceed(getCmd), (0, outValue)) self.assertEqual(v(self.transm.proceed(getCmd)), v((0, outValue)))
def setGetTestNOK(self, cmd, inValue, jail=None): def setGetTestNOK(self, cmd, inValue, jail=None):
setCmd = ["set", cmd, inValue] setCmd = ["set", cmd, inValue]
@ -794,8 +799,11 @@ class TransmitterLogging(TransmitterBase):
**{True: {}, # should work on Linux **{True: {}, # should work on Linux
False: dict( # expect to fail otherwise False: dict( # expect to fail otherwise
outCode=1, outCode=1,
outValue=Exception('Failed to change log target'))} outValue=Exception('Failed to change log target'),
[platform.system() in ('Linux',)]) repr_=True # Exceptions are not comparable apparently
)
}[platform.system() in ('Linux',)]
)
def testLogLevel(self): def testLogLevel(self):
self.setGetTest("loglevel", "HEAVYDEBUG") self.setGetTest("loglevel", "HEAVYDEBUG")