From dc6890709e19567219cc35a561a07dc8cd5d611c Mon Sep 17 00:00:00 2001 From: Xander Johnson Date: Tue, 14 Mar 2017 12:45:56 -0700 Subject: [PATCH] Change ValueError to io.UnsupportedOperation in capture.py. Resolves issue #2276 --- _pytest/capture.py | 3 ++- testing/test_capture.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/_pytest/capture.py b/_pytest/capture.py index eea81ca18..07ec662b6 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -13,6 +13,7 @@ import py import pytest from py.io import TextIO +from io import UnsupportedOperation unicode = py.builtin.text patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'} @@ -448,7 +449,7 @@ class DontReadFromInput: __iter__ = read def fileno(self): - raise ValueError("redirected Stdin is pseudofile, has no fileno()") + raise UnsupportedOperation("redirected Stdin is pseudofile, has no fileno()") def isatty(self): return False diff --git a/testing/test_capture.py b/testing/test_capture.py index 763e28315..978e67b7e 100644 --- a/testing/test_capture.py +++ b/testing/test_capture.py @@ -4,6 +4,7 @@ from __future__ import with_statement import pickle import os import sys +from io import UnsupportedOperation import _pytest._code import py @@ -658,7 +659,7 @@ def test_dontreadfrominput(): pytest.raises(IOError, f.read) pytest.raises(IOError, f.readlines) pytest.raises(IOError, iter, f) - pytest.raises(ValueError, f.fileno) + pytest.raises(UnsupportedOperation, f.fileno) f.close() # just for completeness