Fixed generates decorator
This commit is contained in:
@@ -18,6 +18,9 @@ def generates(attr):
|
|||||||
parts = attr.split('.')
|
parts = attr.split('.')
|
||||||
generator_registry[parts[0]].append(wrapper)
|
generator_registry[parts[0]].append(wrapper)
|
||||||
wrapper.__generates__ = parts[1]
|
wrapper.__generates__ = parts[1]
|
||||||
|
elif isinstance(attr, sa.orm.attributes.InstrumentedAttribute):
|
||||||
|
generator_registry[attr.class_.__name__].append(wrapper)
|
||||||
|
wrapper.__generates__ = attr
|
||||||
else:
|
else:
|
||||||
wrapper.__generates__ = attr
|
wrapper.__generates__ = attr
|
||||||
return wrapper
|
return wrapper
|
||||||
|
@@ -5,8 +5,8 @@ from tests import TestCase
|
|||||||
|
|
||||||
|
|
||||||
class GeneratesTestCase(TestCase):
|
class GeneratesTestCase(TestCase):
|
||||||
def setup_method(self, method):
|
def teardown_method(self, method):
|
||||||
TestCase.setup_method(self, method)
|
TestCase.teardown_method(self, method)
|
||||||
decorators.generator_registry = defaultdict(list)
|
decorators.generator_registry = defaultdict(list)
|
||||||
|
|
||||||
def test_generates_value_before_flush(self):
|
def test_generates_value_before_flush(self):
|
||||||
|
Reference in New Issue
Block a user