diff --git a/test.py b/test.py index 78bdada..366f313 100644 --- a/test.py +++ b/test.py @@ -229,6 +229,9 @@ def test_two_file_pipes(tmpdir): assert w.thread is None printf("some stdout") printf_err("some stderr") + # make sure capture stopped + printf("after stdout") + printf_err("after stderr") with test_stdout.open() as f: assert f.read() == "some stdout\n" diff --git a/wurlitzer.py b/wurlitzer.py index 39089a7..75efe68 100644 --- a/wurlitzer.py +++ b/wurlitzer.py @@ -209,6 +209,7 @@ def _setup_pipe(self, name): real_fd = getattr(sys, '__%s__' % name).fileno() save_fd = os.dup(real_fd) self._save_fds[name] = save_fd + self._real_fds[name] = real_fd try: capture_fd = getattr(self, "_" + name).fileno() @@ -233,7 +234,6 @@ def _setup_pipe(self, name): dup2(pipe_in, real_fd) os.close(pipe_in) - self._real_fds[name] = real_fd # make pipe_out non-blocking flags = fcntl(pipe_out, F_GETFL)