add `encoding` attr to DontReadFromInput
required by https://docs.python.org/2/library/stdtypes.html#file.encoding and used e.g. by ipdb at _import_ time --HG-- branch : dontreadfrominput-encoding
This commit is contained in:
parent
6aa5611ae5
commit
bc4eecbbac
|
@ -428,6 +428,9 @@ class DontReadFromInput:
|
||||||
because in automated test runs it is better to crash than
|
because in automated test runs it is better to crash than
|
||||||
hang indefinitely.
|
hang indefinitely.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
encoding = None
|
||||||
|
|
||||||
def read(self, *args):
|
def read(self, *args):
|
||||||
raise IOError("reading from stdin while output is captured")
|
raise IOError("reading from stdin while output is captured")
|
||||||
readline = read
|
readline = read
|
||||||
|
|
|
@ -1025,6 +1025,18 @@ def test_error_attribute_issue555(testdir):
|
||||||
reprec.assertoutcome(passed=1)
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
|
|
||||||
|
def test_dontreadfrominput_has_encoding(testdir):
|
||||||
|
testdir.makepyfile("""
|
||||||
|
import sys
|
||||||
|
def test_capattr():
|
||||||
|
# should not raise AttributeError
|
||||||
|
assert sys.stdout.encoding
|
||||||
|
assert sys.stderr.encoding
|
||||||
|
""")
|
||||||
|
reprec = testdir.inline_run()
|
||||||
|
reprec.assertoutcome(passed=1)
|
||||||
|
|
||||||
|
|
||||||
def test_pickling_and_unpickling_enocded_file():
|
def test_pickling_and_unpickling_enocded_file():
|
||||||
# See https://bitbucket.org/hpk42/pytest/pull-request/194
|
# See https://bitbucket.org/hpk42/pytest/pull-request/194
|
||||||
# pickle.loads() raises infinite recursion if
|
# pickle.loads() raises infinite recursion if
|
||||||
|
|
Loading…
Reference in New Issue