MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _fixture

Method _fixture

test/orm/test_cascade.py:3655–3715  ·  view source on GitHub ↗
(
        self,
        legacy_is_orphan,
        persistent,
        r1_present,
        r2_present,
        detach_event=True,
    )

Source from the content-addressed store, hash-verified

3653 )
3654
3655 def _fixture(
3656 self,
3657 legacy_is_orphan,
3658 persistent,
3659 r1_present,
3660 r2_present,
3661 detach_event=True,
3662 ):
3663 class Core:
3664 pass
3665
3666 class RelatedOne:
3667 def __init__(self, cores):
3668 self.cores = cores
3669
3670 class RelatedTwo:
3671 def __init__(self, cores):
3672 self.cores = cores
3673
3674 self.mapper_registry.map_imperatively(
3675 Core, self.tables.core, legacy_is_orphan=legacy_is_orphan
3676 )
3677 self.mapper_registry.map_imperatively(
3678 RelatedOne,
3679 self.tables.related_one,
3680 properties={
3681 "cores": relationship(
3682 Core, cascade="all, delete-orphan", backref="r1"
3683 )
3684 },
3685 )
3686 self.mapper_registry.map_imperatively(
3687 RelatedTwo,
3688 self.tables.related_two,
3689 properties={
3690 "cores": relationship(
3691 Core, cascade="all, delete-orphan", backref="r2"
3692 )
3693 },
3694 )
3695 c1 = Core()
3696 if detach_event:
3697 RelatedOne(cores=[c1])
3698 RelatedTwo(cores=[c1])
3699 else:
3700 if r1_present:
3701 RelatedOne(cores=[c1])
3702 if r2_present:
3703 RelatedTwo(cores=[c1])
3704
3705 if persistent:
3706 s = fixture_session()
3707 s.add(c1)
3708 s.flush()
3709
3710 if detach_event:
3711 if not r1_present:
3712 c1.r1 = None

Calls 8

relationshipFunction · 0.90
fixture_sessionFunction · 0.90
CoreClass · 0.85
RelatedOneClass · 0.85
RelatedTwoClass · 0.85
map_imperativelyMethod · 0.80
addMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected