MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_basic

Method test_basic

test/orm/test_attributes.py:235–266  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

233 MyTest, MyTest2 = None, None
234
235 def test_basic(self):
236 class User:
237 pass
238
239 instrumentation.register_class(User)
240 _register_attribute(User, "user_id", uselist=False, useobject=False)
241 _register_attribute(User, "user_name", uselist=False, useobject=False)
242 _register_attribute(
243 User, "email_address", uselist=False, useobject=False
244 )
245 u = User()
246 u.user_id = 7
247 u.user_name = "john"
248 u.email_address = "lala@123.com"
249 self.assert_(
250 u.user_id == 7
251 and u.user_name == "john"
252 and u.email_address == "lala@123.com"
253 )
254 attributes.instance_state(u)._commit_all(attributes.instance_dict(u))
255 self.assert_(
256 u.user_id == 7
257 and u.user_name == "john"
258 and u.email_address == "lala@123.com"
259 )
260 u.user_name = "heythere"
261 u.email_address = "foo@bar.com"
262 self.assert_(
263 u.user_id == 7
264 and u.user_name == "heythere"
265 and u.email_address == "foo@bar.com"
266 )
267
268 def test_pickleness(self):
269 instrumentation.register_class(MyTest)

Callers

nothing calls this directly

Calls 4

_commit_allMethod · 0.80
_register_attributeFunction · 0.70
UserClass · 0.70
assert_Method · 0.45

Tested by

no test coverage detected