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

Function TEST_SUBMODULE

tests/test_async.cpp:12–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include "pybind11_tests.h"
11
12TEST_SUBMODULE(async_module, m) {
13 struct DoesNotSupportAsync {};
14 py::class_<DoesNotSupportAsync>(m, "DoesNotSupportAsync").def(py::init<>());
15 struct SupportsAsync {};
16 py::class_<SupportsAsync>(m, "SupportsAsync")
17 .def(py::init<>())
18 .def("__await__", [](const SupportsAsync &self) -> py::object {
19 static_cast<void>(self);
20 py::object loop = py::module_::import("asyncio.events").attr("get_event_loop")();
21 py::object f = loop.attr("create_future")();
22 f.attr("set_result")(5);
23 return f.attr("__await__")();
24 });
25}

Callers

nothing calls this directly

Calls 2

importFunction · 0.85
attrMethod · 0.80

Tested by

no test coverage detected