2 # Standalone sanity check of context life-cycle.
6 assert mlir
.ir
.Context
._get
_live
_count
() == 0
8 # Create first context.
10 c1
= mlir
.ir
.Context()
11 assert mlir
.ir
.Context
._get
_live
_count
() == 1
13 print("C1 = ", c1_repr
)
15 print("GETTING AGAIN...")
16 c2
= c1
._get_context_again()
18 assert mlir
.ir
.Context
._get
_live
_count
() == 1
19 assert c1_repr
== c2_repr
23 # Make sure new contexts on constructor.
25 c3
= mlir
.ir
.Context()
26 assert mlir
.ir
.Context
._get
_live
_count
() == 2
29 assert c3_repr
!= c1_repr
33 assert mlir
.ir
.Context
._get
_live
_count
() == 1
38 assert mlir
.ir
.Context
._get
_live
_count
() == 1
42 assert mlir
.ir
.Context
._get
_live
_count
() == 0
44 # Create a context, get its capsule and create from capsule.
45 c4
= mlir
.ir
.Context()
46 c4_capsule
= c4
._CAPIPtr
47 assert '"mlir.ir.Context._CAPIPtr"' in repr(c4_capsule
)
48 c5
= mlir
.ir
.Context
._CAPICreate
(c4_capsule
)