File tree 4 files changed +33
-1
lines changed 4 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,7 @@ Javier Domingo Cansino
69
69
Javier Romero
70
70
John Towler
71
71
Jon Sonesen
72
+ Jordan Guymon
72
73
Joshua Bronson
73
74
Jurko Gospodnetić
74
75
Justyna Janczyszyn
Original file line number Diff line number Diff line change 6
6
* Improve error message when passing non-string ids to ``pytest.mark.parametrize `` (`#1857 `_).
7
7
Thanks `@okken `_ for the report and `@nicoddemus `_ for the PR.
8
8
9
- *
9
+ * Add ``buffer `` attribute to stdin stub class ``pytest.capture.DontReadFromInput ``
10
+ Thanks `@joguSD `_ for the PR.
10
11
11
12
*
12
13
14
+ .. _@joguSD : https://github.com/joguSD
13
15
14
16
.. _#1857 : https://github.com/pytest-dev/pytest/issues/1857
15
17
Original file line number Diff line number Diff line change @@ -455,6 +455,13 @@ def isatty(self):
455
455
def close (self ):
456
456
pass
457
457
458
+ @property
459
+ def buffer (self ):
460
+ if sys .version_info >= (3 ,0 ):
461
+ return self
462
+ else :
463
+ raise AttributeError ('redirected stdin has no attribute buffer' )
464
+
458
465
459
466
def _readline_workaround ():
460
467
"""
Original file line number Diff line number Diff line change @@ -662,6 +662,28 @@ def test_dontreadfrominput():
662
662
f .close () # just for completeness
663
663
664
664
665
+ @pytest .mark .skipif ('sys.version_info < (3,)' , reason = 'python2 has no buffer' )
666
+ def test_dontreadfrominput_buffer_python3 ():
667
+ from _pytest .capture import DontReadFromInput
668
+ f = DontReadFromInput ()
669
+ fb = f .buffer
670
+ assert not fb .isatty ()
671
+ pytest .raises (IOError , fb .read )
672
+ pytest .raises (IOError , fb .readlines )
673
+ pytest .raises (IOError , iter , fb )
674
+ pytest .raises (ValueError , fb .fileno )
675
+ f .close () # just for completeness
676
+
677
+
678
+ @pytest .mark .skipif ('sys.version_info >= (3,)' , reason = 'python2 has no buffer' )
679
+ def test_dontreadfrominput_buffer_python2 ():
680
+ from _pytest .capture import DontReadFromInput
681
+ f = DontReadFromInput ()
682
+ with pytest .raises (AttributeError ):
683
+ f .buffer
684
+ f .close () # just for completeness
685
+
686
+
665
687
@pytest .yield_fixture
666
688
def tmpfile (testdir ):
667
689
f = testdir .makepyfile ("" ).open ('wb+' )
You can’t perform that action at this time.
0 commit comments