MCPcopy Create free account
hub / github.com/pybind/pybind11 / test_copy_method

Function test_copy_method

tests/test_methods_and_attributes.py:93–107  ·  view source on GitHub ↗

Issue #443: calling copied methods fails in Python 3

()

Source from the content-addressed store, hash-verified

91
92
93def test_copy_method():
94 """Issue #443: calling copied methods fails in Python 3"""
95
96 m.ExampleMandA.add2c = m.ExampleMandA.add2
97 m.ExampleMandA.add2d = m.ExampleMandA.add2b
98 a = m.ExampleMandA(123)
99 assert a.value == 123
100 a.add2(m.ExampleMandA(-100))
101 assert a.value == 23
102 a.add2b(m.ExampleMandA(20))
103 assert a.value == 43
104 a.add2c(m.ExampleMandA(6))
105 assert a.value == 49
106 a.add2d(m.ExampleMandA(-7))
107 assert a.value == 42
108
109
110def test_properties():

Callers

nothing calls this directly

Calls 2

add2Method · 0.95
ExampleMandAMethod · 0.80

Tested by

no test coverage detected