Fixed generates decorator

This commit is contained in:
Konsta Vesterinen
2013-10-23 15:33:15 +03:00
parent dd8b5b2f13
commit 002b5b69cd
2 changed files with 5 additions and 2 deletions

View File

@@ -18,6 +18,9 @@ def generates(attr):
parts = attr.split('.')
generator_registry[parts[0]].append(wrapper)
wrapper.__generates__ = parts[1]
elif isinstance(attr, sa.orm.attributes.InstrumentedAttribute):
generator_registry[attr.class_.__name__].append(wrapper)
wrapper.__generates__ = attr
else:
wrapper.__generates__ = attr
return wrapper

View File

@@ -5,8 +5,8 @@ from tests import TestCase
class GeneratesTestCase(TestCase):
def setup_method(self, method):
TestCase.setup_method(self, method)
def teardown_method(self, method):
TestCase.teardown_method(self, method)
decorators.generator_registry = defaultdict(list)
def test_generates_value_before_flush(self):