MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _test_class_guards

Method _test_class_guards

test/orm/test_session.py:2604–2642  ·  view source on GitHub ↗
(self, user_arg, is_class=True)

Source from the content-addressed store, hash-verified

2602 )
2603
2604 def _test_class_guards(self, user_arg, is_class=True):
2605 watchdog = set()
2606
2607 def raises_(method, *args, **kw):
2608 watchdog.add(method)
2609 callable_ = getattr(
2610 Session(),
2611 method,
2612 )
2613 if is_class:
2614 assert_raises(
2615 sa.orm.exc.UnmappedClassError, callable_, *args, **kw
2616 )
2617 else:
2618 assert_raises(
2619 exc.NoInspectionAvailable, callable_, *args, **kw
2620 )
2621
2622 raises_("connection", bind_arguments=dict(mapper=user_arg))
2623
2624 raises_(
2625 "execute", text("SELECT 1"), bind_arguments=dict(mapper=user_arg)
2626 )
2627
2628 raises_("get_bind", mapper=user_arg)
2629
2630 raises_(
2631 "scalar", text("SELECT 1"), bind_arguments=dict(mapper=user_arg)
2632 )
2633
2634 raises_(
2635 "scalars", text("SELECT 1"), bind_arguments=dict(mapper=user_arg)
2636 )
2637
2638 eq_(
2639 watchdog,
2640 self._class_methods,
2641 watchdog.symmetric_difference(self._class_methods),
2642 )
2643
2644 def test_join_transaction_mode(self):
2645 with expect_raises_message(

Callers 4

test_missing_stateMethod · 0.95

Calls 3

textFunction · 0.90
eq_Function · 0.90
symmetric_differenceMethod · 0.45

Tested by

no test coverage detected