MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_conflicts

Method test_conflicts

test/orm/test_options.py:1937–1974  ·  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

1935 ),
1936 )
1937 def test_conflicts(self, make_opt, errmsg):
1938 """introduce a new error for conflicting options in SQLAlchemy 2.0.
1939
1940 This case seems to be fairly difficult to come up with randomly
1941 so let's see if we can refuse to guess for this case.
1942
1943 """
1944 users, items, order_items, Order, Item, User, orders = (
1945 self.tables.users,
1946 self.tables.items,
1947 self.tables.order_items,
1948 self.classes.Order,
1949 self.classes.Item,
1950 self.classes.User,
1951 self.tables.orders,
1952 )
1953
1954 self.mapper_registry.map_imperatively(
1955 User, users, properties=dict(orders=relationship(Order))
1956 )
1957 self.mapper_registry.map_imperatively(
1958 Order,
1959 orders,
1960 properties=dict(items=relationship(Item, secondary=order_items)),
1961 )
1962 self.mapper_registry.map_imperatively(Item, items)
1963
1964 sess = fixture_session()
1965
1966 opt = testing.resolve_lambda(
1967 make_opt, User=User, Order=Order, Item=Item
1968 )
1969
1970 if errmsg:
1971 with expect_raises_message(sa.exc.InvalidRequestError, errmsg):
1972 sess.query(User).options(opt)._compile_context()
1973 else:
1974 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