new_contents: class _AssertRaisesBaseContext(object):
  
      def __init__(self, expected, test_case, callable_obj=None,
                   expected_regex=None):
          self.expected = expected
          self.test_case = test_case
          if callable_obj is not None:
              try:
                  self.obj_name = callable_obj.__name__
              except AttributeError:
                  self.obj_name = str(callable_obj)
          else:
              self.obj_name = None
          if isinstance(expected_regex, (bytes, str)):
              expected_regex = re.compile(expected_regex)
          self.expected_regex = expected_regex
          self.msg = None
  
      def _raiseFailure(self, msg):
          raise Exception(msg)
  
      def handle(self, name, callable_obj, args, kwargs):
          """
          If callable_obj is None, assertRaises/Warns is being used as a
          context manager, so check for a 'msg' kwarg and return self.
          If callable_obj is not None, call it passing args and kwargs.
          """
          if callable_obj is None:
              self.msg = kwargs.pop('msg', None)
              return self
          with self:
              callable_obj(*args, **kwargs)
  
  
  
  class _AssertRaisesContext(_AssertRaisesBaseContext):
      """A context manager used to implement TestCase.assertRaises* methods."""
  
      def __enter__(self):
          return self
  
      def __exit__(self, exc_type, exc_value, tb):
          if exc_type is None:
              try:
                  exc_name = self.expected.__name__
              except AttributeError:
                  exc_name = str(self.expected)
              if self.obj_name:
                  self._raiseFailure("{} not raised by {}".format(exc_name,
                                                                  self.obj_name))
              else:
                  self._raiseFailure("{} not raised".format(exc_name))
          if not issubclass(exc_type, self.expected):
              # let unexpected exceptions pass through
              return False
          # store exception, without traceback, for later retrieval
          self.exception = exc_value.with_traceback(None)
          if self.expected_regex is None:
              return True
  
          expected_regex = self.expected_regex
          if not expected_regex.search(str(exc_value)):
              self._raiseFailure('"{}" does not match "{}"'.format(
                       expected_regex.pattern, str(exc_value)))
          return True
  
  
  class Tester:
      
      def assertEqual(self, result, expected):
          if result != expected:
              raise AssertionError('assertEqual, expected %s, got %s' 
                  %(expected, result))
  
      def assertNotEqual(self, result, expected):
          if result == expected:
              raise AssertionError('assertNotEqual, expected %s, got %s' 
                  %(expected, result))
  
      def assertRaises(self, excClass, callableObj=None, *args, **kwargs):
          context = _AssertRaisesContext(excClass, self, callableObj)
          return context.handle('assertRaises', callableObj, args, kwargs)
  
      def assertIs(self, a, b):
          if not a is b:
              raise AssertionError('%s is %s should be true' %(a,b))
  
      def assertIsNot(self, a, b):
          if a is b:
              raise AssertionError('%s is %s should be false' %(a,b))
      
      def assertIn(self, item, container):
          if not item in container:
              raise AssertionError('%s should be in %s' %(item, container))
  
      def assertNotIn(self, item, container):
          if item in container:
              raise AssertionError('%s should not be in %s' %(item, container))
  
      def fail(self, *args):
          print('fail')
          raise Exception(str(args))
          
  tester = Tester()
  assertRaises = tester.assertRaises
  
  if __name__=='__main__':
      t = 1, 2
      assertRaises(TypeError, t, '__setitem__', 0, 1)
      
subject: Add module tester (poor man's unittest)