Merged in davidszotten/pytest/stop_leaking_fds (pull request #206)

stop leaking file descriptors
This commit is contained in:
holger krekel 2014-09-22 15:02:48 +02:00
commit e2c6a77f06
1 changed files with 2 additions and 0 deletions

View File

@ -744,6 +744,7 @@ class TestFDCapture:
cap.done() cap.done()
pytest.raises(AttributeError, cap.suspend) pytest.raises(AttributeError, cap.suspend)
@contextlib.contextmanager @contextlib.contextmanager
def saved_fd(fd): def saved_fd(fd):
new_fd = os.dup(fd) new_fd = os.dup(fd)
@ -751,6 +752,7 @@ def saved_fd(fd):
yield yield
finally: finally:
os.dup2(new_fd, fd) os.dup2(new_fd, fd)
os.close(new_fd)
class TestStdCapture: class TestStdCapture: