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

Method test_conflicts

test/orm/test_options.py:1947–1984  ·  view source on GitHub ↗

introduce a new error for conflicting options in SQLAlchemy 2.0. This case seems to be fairly difficult to come up with randomly so let's see if we can refuse to guess for this case.

(self, make_opt, errmsg)

Source from the content-addressed store, hash-verified

1945 ),
1946 )
1947 def test_conflicts(self, make_opt, errmsg):
1948 """introduce a new error for conflicting options in SQLAlchemy 2.0.
1949
1950 This case seems to be fairly difficult to come up with randomly
1951 so let's see if we can refuse to guess for this case.
1952
1953 """
1954 users, items, order_items, Order, Item, User, orders = (
1955 self.tables.users,
1956 self.tables.items,
1957 self.tables.order_items,
1958 self.classes.Order,
1959 self.classes.Item,
1960 self.classes.User,
1961 self.tables.orders,
1962 )
1963
1964 self.mapper_registry.map_imperatively(
1965 User, users, properties=dict(orders=relationship(Order))
1966 )
1967 self.mapper_registry.map_imperatively(
1968 Order,
1969 orders,
1970 properties=dict(items=relationship(Item, secondary=order_items)),
1971 )
1972 self.mapper_registry.map_imperatively(Item, items)
1973
1974 sess = fixture_session()
1975
1976 opt = testing.resolve_lambda(
1977 make_opt, User=User, Order=Order, Item=Item
1978 )
1979
1980 if errmsg:
1981 with expect_raises_message(sa.exc.InvalidRequestError, errmsg):
1982 sess.query(User).options(opt)._compile_context()
1983 else:
1984 sess.query(User).options(opt)._compile_context()

Callers

nothing calls this directly

Calls 7

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
expect_raises_messageFunction · 0.90
map_imperativelyMethod · 0.80
_compile_contextMethod · 0.80
optionsMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected