def non_production(func): def is_production(): #django specific from django.conf import settings return getattr(settings, "PRODUCTION", False) def wrapped(*args, **kwargs): if is_production(): raise Exception("%s is not meant to be run on a production server" % \ func.__name__) else: return func(*args, **kwargs) return wrapped
Now all you have to do is to apply it to your dev/test only functions:
@non_production def test_something(a, b): pass
Cheers!
KR
No comments:
Post a Comment