MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_noload_issue

Method test_noload_issue

test/orm/test_deprecations.py:2297–2323  ·  view source on GitHub ↗

test #6420. a noload that hits the dynamic loader should have no effect.

(self, type_, user_address_fixture)

Source from the content-addressed store, hash-verified

2295
2296 @testing.combinations(("star",), ("attronly",), argnames="type_")
2297 def test_noload_issue(self, type_, user_address_fixture):
2298 """test #6420. a noload that hits the dynamic loader
2299 should have no effect.
2300
2301 """
2302
2303 User, Address = user_address_fixture()
2304
2305 s = fixture_session()
2306
2307 with expect_noload_deprecation():
2308
2309 if type_ == "star":
2310 u1 = s.query(User).filter_by(id=7).options(noload("*")).first()
2311 assert "name" not in u1.__dict__["name"]
2312 elif type_ == "attronly":
2313 u1 = (
2314 s.query(User)
2315 .filter_by(id=7)
2316 .options(noload(User.addresses))
2317 .first()
2318 )
2319
2320 eq_(u1.__dict__["name"], "jack")
2321
2322 # noload doesn't affect a dynamic loader, because it has no state
2323 eq_(list(u1.addresses), [Address(id=1)])
2324
2325
2326class WriteOnlyTest(_WriteOnlyFixture, _fixtures.FixtureTest):

Callers

nothing calls this directly

Calls 9

fixture_sessionFunction · 0.90
noloadFunction · 0.90
eq_Function · 0.90
AddressClass · 0.70
firstMethod · 0.45
optionsMethod · 0.45
filter_byMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected