MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_get_one_2

Method test_get_one_2

test/orm/test_session.py:704–720  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

702 is_not(u, u2)
703
704 def test_get_one_2(self):
705 users, User = self.tables.users, self.classes.User
706 self.mapper_registry.map_imperatively(User, users)
707
708 sess = fixture_session()
709 user1 = User(id=1, name="u1")
710
711 sess.add(user1)
712 sess.commit()
713
714 u1 = sess.get_one(User, user1.id)
715 eq_(user1.name, u1.name)
716
717 with expect_raises_message(
718 sa.exc.NoResultFound, "No row was found when one was required"
719 ):
720 sess.get_one(User, 2)
721
722 def test_delete_all(self):
723 users, User = self.tables.users, self.classes.User

Callers

nothing calls this directly

Calls 8

fixture_sessionFunction · 0.90
eq_Function · 0.90
expect_raises_messageFunction · 0.90
map_imperativelyMethod · 0.80
UserClass · 0.70
addMethod · 0.45
commitMethod · 0.45
get_oneMethod · 0.45

Tested by

no test coverage detected