src/tests/pkg5unittest.py
changeset 2219 60ad60f7592c
parent 2218 f025ba1faae7
child 2223 2da8c49e53dc
equal deleted inserted replaced
2218:f025ba1faae7 2219:60ad60f7592c
    96 import pkg.client.api
    96 import pkg.client.api
    97 import pkg.client.progress
    97 import pkg.client.progress
    98 
    98 
    99 # Version test suite is known to work with.
    99 # Version test suite is known to work with.
   100 PKG_CLIENT_NAME = "pkg"
   100 PKG_CLIENT_NAME = "pkg"
   101 CLIENT_API_VERSION = 52
   101 CLIENT_API_VERSION = 53
   102 
   102 
   103 ELIDABLE_ERRORS = [ TestSkippedException, depotcontroller.DepotStateException ]
   103 ELIDABLE_ERRORS = [ TestSkippedException, depotcontroller.DepotStateException ]
   104 
   104 
   105 class Pkg5CommonException(AssertionError):
   105 class Pkg5CommonException(AssertionError):
   106         def __init__(self, com = ""):
   106         def __init__(self, com = ""):
   205                 setup_logging(self)
   205                 setup_logging(self)
   206 
   206 
   207         def __str__(self):
   207         def __str__(self):
   208                 return "%s.py %s.%s" % (self.__class__.__module__,
   208                 return "%s.py %s.%s" % (self.__class__.__module__,
   209                     self.__class__.__name__, self._testMethodName)
   209                     self.__class__.__name__, self._testMethodName)
       
   210 
       
   211         def assertRaisesStringify(self, excClass, callableObj, *args, **kwargs):
       
   212                 """Perform the same logic as assertRaises, but then verify that
       
   213                 the exception raised can be stringified."""
       
   214 
       
   215                 try:
       
   216                         callableObj(*args, **kwargs)
       
   217                 except excClass, e:
       
   218                         str(e)
       
   219                         return
       
   220                 else:
       
   221                         raise self.failureException, "%s not raised" % excClass
   210 
   222 
   211         #
   223         #
   212         # Uses property() to implements test_root as a read-only attribute.
   224         # Uses property() to implements test_root as a read-only attribute.
   213         #
   225         #
   214         test_root = property(fget=lambda self: self.__test_root)
   226         test_root = property(fget=lambda self: self.__test_root)