1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
import functools
import unittest
from stronghold import decorators
class StrongholdDecoratorTests(unittest.TestCase):
def test_public_decorator_sets_attr(self):
@decorators.public
def function():
pass
self.assertTrue(function.STRONGHOLD_IS_PUBLIC)
def test_public_decorator_sets_attr_with_nested_decorators(self):
def stub_decorator(func):
return func
@decorators.public
@stub_decorator
def inner_function():
pass
self.assertTrue(inner_function.STRONGHOLD_IS_PUBLIC)
def test_public_decorator_works_with_partials(self):
def function():
pass
partial = functools.partial(function)
decorators.public(partial)
self.assertTrue(function.STRONGHOLD_IS_PUBLIC)
|