MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/ext/test_hybrid.py:56–109  ·  view source on GitHub ↗
(self, use_inplace=False, use_classmethod=False)

Source from the content-addressed store, hash-verified

54 __dialect__ = "default"
55
56 def _fixture(self, use_inplace=False, use_classmethod=False):
57 Base = declarative_base()
58
59 class UCComparator(hybrid.Comparator):
60 def __eq__(self, other):
61 if other is None:
62 return self.expression is None
63 else:
64 return func.upper(self.expression) == func.upper(other)
65
66 class A(Base):
67 __tablename__ = "a"
68 id = Column(Integer, primary_key=True)
69
70 _value = Column("value", String)
71
72 @hybrid.hybrid_property
73 def value(self):
74 "This is a docstring"
75 return self._value - 5
76
77 if use_classmethod:
78 if use_inplace:
79
80 @value.inplace.comparator
81 @classmethod
82 def _value_comparator(cls):
83 return UCComparator(cls._value)
84
85 else:
86
87 @value.comparator
88 @classmethod
89 def value(cls):
90 return UCComparator(cls._value)
91
92 else:
93 if use_inplace:
94
95 @value.inplace.comparator
96 def _value_comparator(cls):
97 return UCComparator(cls._value)
98
99 else:
100
101 @value.comparator
102 def value(cls):
103 return UCComparator(cls._value)
104
105 @value.setter
106 def value(self, v):
107 self._value = v + 5
108
109 return A
110
111 def test_set_get(self):
112 A = self._fixture()

Callers 7

test_set_getMethod · 0.95
test_valueMethod · 0.95
test_aliased_valueMethod · 0.95
test_queryMethod · 0.95
test_aliased_queryMethod · 0.95
test_aliased_filterMethod · 0.95
test_docstringMethod · 0.95

Calls 1

declarative_baseFunction · 0.90

Tested by

no test coverage detected