@@ -21,96 +21,94 @@ def test_basic():
2121 raise Exception
2222 with RaiseAssertor (Exception ):
2323 raise TypeError
24-
24+
2525 def f ():
2626 with RaiseAssertor (ZeroDivisionError ):
2727 raise MyException
2828 nose .tools .assert_raises (Failure , f )
2929 with RaiseAssertor (Failure ):
3030 f ()
31-
31+
3232 def g ():
3333 with RaiseAssertor (Exception ):
3434 pass
3535 nose .tools .assert_raises (Failure , g )
3636 with RaiseAssertor (Failure ):
3737 g ()
38-
38+
3939 def h ():
4040 with RaiseAssertor (RuntimeError , 'booga' ):
4141 pass
4242 nose .tools .assert_raises (Failure , h )
4343 with RaiseAssertor (Failure ):
4444 h ()
45-
45+
4646 with RaiseAssertor (Failure ) as raise_assertor :
4747 assert isinstance (raise_assertor , RaiseAssertor )
4848 with RaiseAssertor (RuntimeError ):
4949 {}[0 ]
50-
50+
5151 assert isinstance (raise_assertor .exception , Exception )
52-
52+
5353
5454def test_decorator ():
5555 '''Test using `RaiseAssertor` as a decorator.'''
5656 @RaiseAssertor (ZeroDivisionError )
5757 def f ():
5858 1 / 0
59-
59+
6060 f ()
61-
61+
6262 cute_testing .assert_polite_wrapper (f )
6363
64-
64+
6565def test_string ():
6666 '''
6767 Test using `RaiseAssertor` specifying sub-string of the exception message.
6868 '''
6969 with RaiseAssertor (Exception , 'wer' ):
7070 raise TypeError ('123qwerty456' )
71-
71+
7272 with RaiseAssertor (Failure ):
7373 with RaiseAssertor (Exception , 'ooga booga' ):
7474 raise TypeError ('123qwerty456' )
75-
75+
7676 with RaiseAssertor (Failure ):
7777 with RaiseAssertor (OSError , 'wer' ):
7878 raise SyntaxError ('123qwerty456' )
79-
80-
79+
80+
8181def test_regex ():
8282 '''
8383 Test using `RaiseAssertor` specifying regex pattern for exception message.
8484 '''
8585 with RaiseAssertor (Exception , re .compile (r'^123\w*?456$' )):
8686 raise TypeError ('123qwerty456' )
87-
87+
8888 with RaiseAssertor (Failure ):
8989 with RaiseAssertor (Exception , re .compile ('^ooga b?ooga$' )):
9090 raise TypeError ('123qwerty456' )
91-
91+
9292 with RaiseAssertor (Failure ):
9393 with RaiseAssertor (OSError , re .compile (r'^123\w*?456$' )):
9494 raise SyntaxError ('123qwerty456' )
95-
95+
9696
9797def test_assert_exact_type ():
9898 '''Test `RaiseAssertor`'s `assert_exact_type` option.'''
9999 with RaiseAssertor (LookupError ):
100100 raise KeyError ("Look at me, I'm a KeyError" )
101-
101+
102102 error_message = (
103- "The exception `KeyError(\" Look at me, I'm a KeyError\" ,)` was "
104- "raised, and it *is* an instance of the `LookupError` we were "
103+ "was raised, and it *is* an instance of the `LookupError` we were "
105104 "expecting; but its type is not `LookupError`, it's `KeyError`, which "
106105 "is a subclass of `LookupError`, but you specified "
107106 "`assert_exact_type=True`, so subclasses aren't acceptable."
108107 )
109-
108+
110109 with RaiseAssertor (Failure , error_message ):
111110 with RaiseAssertor (LookupError , assert_exact_type = True ):
112- raise KeyError ("Look at me, I'm a KeyError" )
113-
114-
115-
116-
111+ raise KeyError ("Look at me, I'm a KeyError" )
112+
113+
114+
0 commit comments