mirror of
https://github.com/pybind/pybind11.git
synced 2026-03-14 20:27:47 +00:00
feat: py::prepend tag (#1131)
* feat: add a priority overload with py::prepend * doc: fix wording as suggested by rwgk * feat: add get_pointer * refactor: is_prepended -> prepend (internal) * docs: suggestion from @wjakob * tests: add test covering get_pointer/set_pointer
This commit is contained in:
@@ -438,3 +438,25 @@ def test_ref_qualified():
|
||||
r.refQualified(17)
|
||||
assert r.value == 17
|
||||
assert r.constRefQualified(23) == 40
|
||||
|
||||
|
||||
def test_overload_ordering():
|
||||
'Check to see if the normal overload order (first defined) and prepend overload order works'
|
||||
assert m.overload_order("string") == 1
|
||||
assert m.overload_order(0) == 4
|
||||
|
||||
# Different for Python 2 vs. 3
|
||||
uni_name = type(u"").__name__
|
||||
|
||||
assert "1. overload_order(arg0: int) -> int" in m.overload_order.__doc__
|
||||
assert "2. overload_order(arg0: {}) -> int".format(uni_name) in m.overload_order.__doc__
|
||||
assert "3. overload_order(arg0: {}) -> int".format(uni_name) in m.overload_order.__doc__
|
||||
assert "4. overload_order(arg0: int) -> int" in m.overload_order.__doc__
|
||||
|
||||
with pytest.raises(TypeError) as err:
|
||||
m.overload_order(1.1)
|
||||
|
||||
assert "1. (arg0: int) -> int" in str(err.value)
|
||||
assert "2. (arg0: {}) -> int".format(uni_name) in str(err.value)
|
||||
assert "3. (arg0: {}) -> int".format(uni_name) in str(err.value)
|
||||
assert "4. (arg0: int) -> int" in str(err.value)
|
||||
|
||||
Reference in New Issue
Block a user