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

Method test_basic

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

Source from the content-addressed store, hash-verified

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