コード例 #1
0
ファイル: matchers.py プロジェクト: Alexandr-Galko/samba
    def __init__(self, exception):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked.
        """
        Matcher.__init__(self)
        self.expected = exception
        self._is_instance = type(self.expected) not in classtypes()
コード例 #2
0
ファイル: matchers.py プロジェクト: fendouzhe660/dd-wrt
    def __init__(self, exception):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked.
        """
        Matcher.__init__(self)
        self.expected = exception
        self._is_instance = type(self.expected) not in classtypes()
コード例 #3
0
    def __init__(self, exception, value_re=None):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked.
        :param value_re: If 'exception' is a type, and the matchee exception
            is of the right type, then the 'str()' of the matchee exception
            is matched against this regular expression.
        """
        Matcher.__init__(self)
        self.expected = exception
        self.value_re = value_re
        self._is_instance = type(self.expected) not in classtypes()
コード例 #4
0
    def __init__(self, exception, value_re=None):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked.
        :param value_re: If 'exception' is a type, and the matchee exception
            is of the right type, then the 'str()' of the matchee exception
            is matched against this regular expression.
        """
        Matcher.__init__(self)
        self.expected = exception
        self.value_re = value_re
        self._is_instance = type(self.expected) not in classtypes()
コード例 #5
0
ファイル: run.py プロジェクト: elopio/testtools-textresult
 def runTests(self):
     if self.catchbreak and getattr(unittest, "installHandler", None) is not None:
         unittest.installHandler()
     if self.testRunner is None:
         self.testRunner = TestToolsTestRunner
     if isinstance(self.testRunner, classtypes()):
         try:
             testRunner = self.testRunner(verbosity=self.verbosity, failfast=self.failfast, buffer=self.buffer)
         except TypeError:
             # didn't accept the verbosity, buffer or failfast arguments
             testRunner = self.testRunner()
     else:
         # it is assumed to be a TestRunner instance
         testRunner = self.testRunner
     self.result = testRunner.run(self.test)
     if self.exit:
         sys.exit(not self.result.wasSuccessful())
コード例 #6
0
ファイル: run.py プロジェクト: cpatulea/samba
 def runTests(self):
     if (self.catchbreak
             and getattr(unittest, 'installHandler', None) is not None):
         unittest.installHandler()
     if self.testRunner is None:
         self.testRunner = runner.TextTestRunner
     if isinstance(self.testRunner, classtypes()):
         try:
             testRunner = self.testRunner(verbosity=self.verbosity,
                                          failfast=self.failfast,
                                          buffer=self.buffer)
         except TypeError:
             # didn't accept the verbosity, buffer or failfast arguments
             testRunner = self.testRunner()
     else:
         # it is assumed to be a TestRunner instance
         testRunner = self.testRunner
     self.result = testRunner.run(self.test)
     if self.exit:
         sys.exit(not self.result.wasSuccessful())
コード例 #7
0
ファイル: matchers.py プロジェクト: z3v2cicidi/pth-toolkit
    def __init__(self, exception, value_re=None):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked. If a tuple is given, then as with isinstance, any of the
            types in the tuple matching is sufficient to match.
        :param value_re: If 'exception' is a type, and the matchee exception
            is of the right type, then match against this.  If value_re is a
            string, then assume value_re is a regular expression and match
            the str() of the exception against it.  Otherwise, assume value_re
            is a matcher, and match the exception against it.
        """
        Matcher.__init__(self)
        self.expected = exception
        if istext(value_re):
            value_re = AfterPreproccessing(str, MatchesRegex(value_re), False)
        self.value_re = value_re
        self._is_instance = type(self.expected) not in classtypes() + (tuple, )
コード例 #8
0
    def __init__(self, exception, value_re=None):
        """Create a MatchesException that will match exc_info's for exception.

        :param exception: Either an exception instance or type.
            If an instance is given, the type and arguments of the exception
            are checked. If a type is given only the type of the exception is
            checked. If a tuple is given, then as with isinstance, any of the
            types in the tuple matching is sufficient to match.
        :param value_re: If 'exception' is a type, and the matchee exception
            is of the right type, then match against this.  If value_re is a
            string, then assume value_re is a regular expression and match
            the str() of the exception against it.  Otherwise, assume value_re
            is a matcher, and match the exception against it.
        """
        Matcher.__init__(self)
        self.expected = exception
        if istext(value_re):
            value_re = AfterPreproccessing(str, MatchesRegex(value_re), False)
        self.value_re = value_re
        self._is_instance = type(self.expected) not in classtypes() + (tuple,)