mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-26 23:22:01 +00:00
Merge branch 'pybind:master' into master
This commit is contained in:
commit
7fa86a30db
@ -109,6 +109,11 @@ TEST_SUBMODULE(pytypes, m) {
|
|||||||
m.def("get_iterator", [] { return py::iterator(); });
|
m.def("get_iterator", [] { return py::iterator(); });
|
||||||
// test_iterable
|
// test_iterable
|
||||||
m.def("get_iterable", [] { return py::iterable(); });
|
m.def("get_iterable", [] { return py::iterable(); });
|
||||||
|
m.def("get_frozenset_from_iterable",
|
||||||
|
[](const py::iterable &iter) { return py::frozenset(iter); });
|
||||||
|
m.def("get_list_from_iterable", [](const py::iterable &iter) { return py::list(iter); });
|
||||||
|
m.def("get_set_from_iterable", [](const py::iterable &iter) { return py::set(iter); });
|
||||||
|
m.def("get_tuple_from_iterable", [](const py::iterable &iter) { return py::tuple(iter); });
|
||||||
// test_float
|
// test_float
|
||||||
m.def("get_float", [] { return py::float_(0.0f); });
|
m.def("get_float", [] { return py::float_(0.0f); });
|
||||||
// test_list
|
// test_list
|
||||||
|
@ -26,6 +26,22 @@ def test_iterator(doc):
|
|||||||
assert doc(m.get_iterator) == "get_iterator() -> Iterator"
|
assert doc(m.get_iterator) == "get_iterator() -> Iterator"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"pytype, from_iter_func",
|
||||||
|
[
|
||||||
|
(frozenset, m.get_frozenset_from_iterable),
|
||||||
|
(list, m.get_list_from_iterable),
|
||||||
|
(set, m.get_set_from_iterable),
|
||||||
|
(tuple, m.get_tuple_from_iterable),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_from_iterable(pytype, from_iter_func):
|
||||||
|
my_iter = iter(range(10))
|
||||||
|
s = from_iter_func(my_iter)
|
||||||
|
assert type(s) == pytype
|
||||||
|
assert s == pytype(range(10))
|
||||||
|
|
||||||
|
|
||||||
def test_iterable(doc):
|
def test_iterable(doc):
|
||||||
assert doc(m.get_iterable) == "get_iterable() -> Iterable"
|
assert doc(m.get_iterable) == "get_iterable() -> Iterable"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user