예제 #1
0
 def raise_keyb_from_match():
     if sys.version_info > (2, 5):
         matcher = Raises(MatchesException(Exception))
     else:
         # On Python 2.4 KeyboardInterrupt is a StandardError subclass
         # but should propogate from less generic exception matchers
         matcher = Raises(MatchesException(EnvironmentError))
     matcher.match(self.raiser)
예제 #2
0
 def test_KeyboardInterrupt_propogates(self):
     # The default 'it raised' propogates KeyboardInterrupt.
     match_keyb = Raises(MatchesException(KeyboardInterrupt))
     def raise_keyb_from_match():
         matcher = Raises()
         matcher.match(self.raiser)
     self.assertThat(raise_keyb_from_match, match_keyb)
예제 #3
0
 def test_KeyboardInterrupt_match_Exception_propogates(self):
     # If the raised exception isn't matched, and it is not a subclass of
     # Exception, it is propogated.
     match_keyb = Raises(MatchesException(KeyboardInterrupt))
     def raise_keyb_from_match():
         matcher = Raises(MatchesException(Exception))
         matcher.match(self.raiser)
     self.assertThat(raise_keyb_from_match, match_keyb)
예제 #4
0
class TestRaisesInterface(TestCase, TestMatchersInterface):

    matches_matcher = Raises()
    def boom():
        raise Exception('foo')
    matches_matches = [boom]
    matches_mismatches = [lambda:None]

    # Tricky to get function objects to render constantly, and the interfaces
    # helper uses assertEqual rather than (for instance) DocTestMatches.
    str_examples = []

    describe_examples = []
예제 #5
0
 def raise_keyb_from_match():
     if sys.version_info > (2, 5):
         matcher = Raises(MatchesException(Exception))
     else:
         # On Python 2.4 KeyboardInterrupt is a StandardError subclass
         # but should propogate from less generic exception matchers
         matcher = Raises(MatchesException(EnvironmentError))
     matcher.match(self.raiser)
예제 #6
0
    def test_KeyboardInterrupt_match_Exception_propogates(self):
        # If the raised exception isn't matched, and it is not a subclass of
        # Exception, it is propogated.
        match_keyb = Raises(MatchesException(KeyboardInterrupt))

        def raise_keyb_from_match():
            if sys.version_info > (2, 5):
                matcher = Raises(MatchesException(Exception))
            else:
                # On Python 2.4 KeyboardInterrupt is a StandardError subclass
                # but should propogate from less generic exception matchers
                matcher = Raises(MatchesException(EnvironmentError))
            matcher.match(self.raiser)

        self.assertThat(raise_keyb_from_match, match_keyb)
예제 #7
0
 def raise_keyb_from_match():
     matcher = Raises(MatchesException(Exception))
     matcher.match(self.raiser)
예제 #8
0
 def raise_keyb_from_match():
     matcher = Raises()
     matcher.match(self.raiser)
예제 #9
0
 def test_KeyboardInterrupt_matched(self):
     # When KeyboardInterrupt is matched, it is swallowed.
     matcher = Raises(MatchesException(KeyboardInterrupt))
     self.assertThat(self.raiser, matcher)