Spaces Data
Minimal test - lines (112, 129)
path: .spaces[6].metrics.loc.cloc
old: 6.0
new: 7.0
path: .spaces[6].metrics.loc.blank
old: 1.0
new: 0.0
path: .spaces[6].metrics.mi.mi_sei
old: 101.87923911244008
new: 104.02021189618192
Code
def expensive(fn):
"""A decorator to indicate that a method shouldn't be called more than once.
Normally, this does nothing. During testing, this raises an exception if
called more than once.
"""
if env.TESTING:
attr = "_once_" + fn.__name__
def _wrapper(self):
if hasattr(self, attr):
raise AssertionError("Shouldn't have called %s more than once" % fn.__name__)
setattr(self, attr, True)
return fn(self)
return _wrapper
else:
return fn # pragma: not testing