17 m_sub.def(
"submodule_func", []() {
return "submodule_func()"; });
26 std::string
toString() {
return "A[" + std::to_string(v) +
"]"; }
30 py::class_<A>(m_sub,
"A")
40 A &get_a1() {
return a1; }
41 A &get_a2() {
return a2; }
46 py::class_<B>(m_sub,
"B")
48 .def(
"get_a1", &B::get_a1,
"Return the internal A 1", py::return_value_policy::reference_internal)
49 .def(
"get_a2", &B::get_a2,
"Return the internal A 2", py::return_value_policy::reference_internal)
50 .def_readwrite(
"a1", &B::a1)
51 .def_readwrite(
"a2", &B::a2);
53 m.attr(
"OD") = py::module::import(
"collections").attr(
"OrderedDict");
57 m.def(
"duplicate_registration", []() {
61 class DupeException { };
64 auto failures = py::list();
66 py::class_<Dupe1>(dm,
"Dupe1");
67 py::class_<Dupe2>(dm,
"Dupe2");
68 dm.def(
"dupe1_factory", []() {
return Dupe1(); });
69 py::exception<DupeException>(dm,
"DupeException");
72 py::class_<Dupe1>(dm,
"Dupe1");
73 failures.append(
"Dupe1 class");
74 }
catch (std::runtime_error &) {}
76 dm.def(
"Dupe1", []() {
return Dupe1(); });
77 failures.append(
"Dupe1 function");
78 }
catch (std::runtime_error &) {}
80 py::class_<Dupe3>(dm,
"dupe1_factory");
81 failures.append(
"dupe1_factory");
82 }
catch (std::runtime_error &) {}
84 py::exception<Dupe3>(dm,
"Dupe2");
85 failures.append(
"Dupe2");
86 }
catch (std::runtime_error &) {}
88 dm.def(
"DupeException", []() {
return 30; });
89 failures.append(
"DupeException1");
90 }
catch (std::runtime_error &) {}
92 py::class_<DupeException>(dm,
"DupeException");
93 failures.append(
"DupeException2");
94 }
catch (std::runtime_error &) {}
void print_destroyed(T *inst, Values &&...values)
std::string toString(T t, std::ios_base &(*f)(std::ios_base &))
void print_copy_assigned(T *inst, Values &&...values)
void print_copy_created(T *inst, Values &&...values)
void print_default_created(T *inst, Values &&...values)
TEST_SUBMODULE(modules, m)
void print_created(T *inst, Values &&...values)