MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_basic

Method test_basic

test/ext/test_extendedattr.py:237–273  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

235 )
236
237 def test_basic(self):
238 for base in (object, MyBaseClass, MyClass):
239
240 class User(base):
241 pass
242
243 register_class(User)
244 _register_attribute(
245 User, "user_id", uselist=False, useobject=False
246 )
247 _register_attribute(
248 User, "user_name", uselist=False, useobject=False
249 )
250 _register_attribute(
251 User, "email_address", uselist=False, useobject=False
252 )
253
254 u = User()
255 u.user_id = 7
256 u.user_name = "john"
257 u.email_address = "lala@123.com"
258
259 eq_(u.user_id, 7)
260 eq_(u.user_name, "john")
261 eq_(u.email_address, "lala@123.com")
262 attributes.instance_state(u)._commit_all(
263 attributes.instance_dict(u)
264 )
265 eq_(u.user_id, 7)
266 eq_(u.user_name, "john")
267 eq_(u.email_address, "lala@123.com")
268
269 u.user_name = "heythere"
270 u.email_address = "foo@bar.com"
271 eq_(u.user_id, 7)
272 eq_(u.user_name, "heythere")
273 eq_(u.email_address, "foo@bar.com")
274
275 def test_deferred(self):
276 for base in (object, MyBaseClass, MyClass):

Callers

nothing calls this directly

Calls 5

register_classFunction · 0.90
eq_Function · 0.90
_commit_allMethod · 0.80
_register_attributeFunction · 0.70
UserClass · 0.70

Tested by

no test coverage detected