MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_options_merge

Method test_options_merge

test/sql/test_utils.py:117–153  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

115 o1 += {"foo": "f", "bar": "b"}
116
117 def test_options_merge(self):
118 class opt1(sql_base.CacheableOptions):
119 _cache_key_traversal = []
120
121 class opt2(sql_base.CacheableOptions):
122 _cache_key_traversal = []
123
124 foo = "bar"
125
126 class opt3(sql_base.CacheableOptions):
127 _cache_key_traversal = []
128
129 foo = "bar"
130 bat = "hi"
131
132 o2 = opt2.safe_merge(opt1)
133 eq_(o2.__dict__, {})
134 eq_(o2.foo, "bar")
135
136 assert_raises_message(
137 TypeError,
138 r"other element .*opt2.* is not empty, is not of type .*opt1.*, "
139 r"and contains attributes not covered here .*'foo'.*",
140 opt1.safe_merge,
141 opt2,
142 )
143
144 o2 = opt2 + {"foo": "bat"}
145 o3 = opt2.safe_merge(o2)
146
147 eq_(o3.foo, "bat")
148
149 o4 = opt3.safe_merge(o2)
150 eq_(o4.foo, "bat")
151 eq_(o4.bat, "hi")
152
153 assert_raises(TypeError, opt2.safe_merge, o4)
154
155 @testing.combinations(
156 (column("q"), [column("q")]),

Callers

nothing calls this directly

Calls 4

eq_Function · 0.90
assert_raises_messageFunction · 0.90
assert_raisesFunction · 0.90
safe_mergeMethod · 0.80

Tested by

no test coverage detected