File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -169,19 +169,19 @@ def inc(self, amount=1):
169
169
self ._value += amount
170
170
171
171
@contextmanager
172
- def trackBlockRaises (self ):
172
+ def countBlockExceptions (self ):
173
173
"""Decorator to increment if a block raises an exception."""
174
174
try :
175
175
yield
176
176
except Exception , e :
177
177
self .inc ()
178
178
raise e
179
179
180
- def trackFunctionRaises (self , f ):
180
+ def countFunctionExceptions (self , f ):
181
181
"""Decorator to increment if a function raises an exception."""
182
182
@wraps (f )
183
183
def wrapper (* args , ** kwargs ):
184
- with self .trackBlockRaises ():
184
+ with self .countBlockExceptions ():
185
185
return f (* args , ** kwargs )
186
186
return wrapper
187
187
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def test_negative_increment_raises(self):
19
19
self .assertRaises (ValueError , self .counter .inc , - 1 )
20
20
21
21
def test_function_decorator (self ):
22
- @self .counter .trackFunctionRaises
22
+ @self .counter .countFunctionExceptions
23
23
def f (r ):
24
24
if r :
25
25
raise Exception
@@ -34,12 +34,12 @@ def f(r):
34
34
self .assertEquals (1 , self .registry .get_sample_value ('c' ))
35
35
36
36
def test_block_decorator (self ):
37
- with self .counter .trackBlockRaises ():
37
+ with self .counter .countBlockExceptions ():
38
38
pass
39
39
self .assertEquals (0 , self .registry .get_sample_value ('c' ))
40
40
raised = False
41
41
try :
42
- with self .counter .trackBlockRaises ():
42
+ with self .counter .countBlockExceptions ():
43
43
raise Exception
44
44
except :
45
45
raised = True
You can’t perform that action at this time.
0 commit comments