20 std::cout << std::flush;
34 m.def(
"captured_output_default", [](std::string
msg) {
35 py::scoped_ostream_redirect redir;
36 std::cout << msg << std::flush;
39 m.def(
"captured_output", [](std::string msg) {
40 py::scoped_ostream_redirect redir(std::cout, py::module::import(
"sys").attr(
"stdout"));
41 std::cout << msg << std::flush;
45 py::call_guard<py::scoped_ostream_redirect>(),
48 m.def(
"captured_err", [](std::string msg) {
49 py::scoped_ostream_redirect redir(std::cerr, py::module::import(
"sys").attr(
"stderr"));
50 std::cerr << msg << std::flush;
56 py::call_guard<py::scoped_ostream_redirect, py::scoped_estream_redirect>(),
59 m.def(
"raw_output", [](std::string msg) {
60 std::cout << msg << std::flush;
63 m.def(
"raw_err", [](std::string msg) {
64 std::cerr << msg << std::flush;
67 m.def(
"captured_dual", [](std::string msg, std::string emsg) {
68 py::scoped_ostream_redirect redirout(std::cout, py::module::import(
"sys").attr(
"stdout"));
69 py::scoped_ostream_redirect redirerr(std::cerr, py::module::import(
"sys").attr(
"stderr"));
70 std::cout << msg << std::flush;
71 std::cerr << emsg << std::flush;
void noisy_function(std::string msg, bool flush)
void noisy_funct_dual(std::string msg, std::string emsg)
class_< detail::OstreamRedirect > add_ostream_redirect(module m, std::string name="ostream_redirect")
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
TEST_SUBMODULE(iostream, m)