File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 55from pybind11_tests import class_sh_disowning as m
66
77
8+ def is_disowned (obj ):
9+ try :
10+ obj .get ()
11+ except ValueError :
12+ return True
13+ return False
14+
15+
816def test_same_twice ():
917 while True :
1018 obj1a = m .Atype1 (57 )
1119 obj1b = m .Atype1 (62 )
1220 assert m .same_twice (obj1a , obj1b ) == (57 * 10 + 1 ) * 100 + (62 * 10 + 1 ) * 10
21+ assert is_disowned (obj1a )
22+ assert is_disowned (obj1b )
1323 obj1c = m .Atype1 (0 )
1424 with pytest .raises (ValueError ):
1525 # Disowning works for one argument, but not both.
1626 m .same_twice (obj1c , obj1c )
17- with pytest .raises (ValueError ):
18- obj1c .get ()
27+ assert is_disowned (obj1c )
1928 return # Comment out for manual leak checking (use `top` command).
2029
2130
@@ -25,6 +34,8 @@ def test_mixed():
2534 obj1a = m .Atype1 (90 )
2635 obj2a = m .Atype2 (25 )
2736 assert m .mixed (obj1a , obj2a ) == (90 * 10 + 1 ) * 200 + (25 * 10 + 2 ) * 20
37+ assert is_disowned (obj1a )
38+ assert is_disowned (obj2a )
2839
2940 # The C++ order of evaluation of function arguments is (unfortunately) unspecified:
3041 # https://en.cppreference.com/w/cpp/language/eval_order
@@ -40,13 +51,6 @@ def test_mixed():
4051 # the already disowned obj1a fails as expected.
4152 m .mixed (obj1a , obj2b )
4253
43- def is_disowned (obj ):
44- try :
45- obj .get ()
46- except ValueError :
47- return True
48- return False
49-
5054 # Either obj1b or obj2b was disowned in the expected failed m.mixed() calls above, but not
5155 # both.
5256 is_disowned_results = (is_disowned (obj1b ), is_disowned (obj2b ))
You can’t perform that action at this time.
0 commit comments