File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import io
2+ import os
3+ import sys
4+
5+ import pytest
6+
7+ from progressbar import utils
8+
9+
10+ def test_wrappingio ():
11+ # Test the wrapping of our version of sys.stdout` ` q
12+ fd = utils .WrappingIO (sys .stdout )
13+ assert fd .fileno ()
14+ assert not fd .isatty ()
15+
16+ assert not fd .read ()
17+ assert not fd .readline ()
18+ assert not fd .readlines ()
19+ assert fd .readable ()
20+
21+ assert not fd .seek (0 )
22+ assert fd .seekable ()
23+ assert not fd .tell ()
24+
25+ assert not fd .truncate ()
26+ assert fd .writable ()
27+ assert fd .write ('test' )
28+ assert not fd .writelines (['test' ])
29+
30+ with pytest .raises (StopIteration ):
31+ next (fd )
32+ with pytest .raises (StopIteration ):
33+ next (iter (fd ))
34+
35+
36+ def test_wrapping_stringio ():
37+ # Test the wrapping of our version of sys.stdout` ` q
38+ string_io = io .StringIO ()
39+ fd = utils .WrappingIO (string_io )
40+ with fd :
41+ with pytest .raises (io .UnsupportedOperation ):
42+ fd .fileno ()
43+
44+ assert not fd .isatty ()
45+
46+ assert not fd .read ()
47+ assert not fd .readline ()
48+ assert not fd .readlines ()
49+ assert fd .readable ()
50+
51+ assert not fd .seek (0 )
52+ assert fd .seekable ()
53+ assert not fd .tell ()
54+
55+ assert not fd .truncate ()
56+ assert fd .writable ()
57+ assert fd .write ('test' )
58+ assert not fd .writelines (['test' ])
59+
60+ with pytest .raises (StopIteration ):
61+ next (fd )
62+ with pytest .raises (StopIteration ):
63+ next (iter (fd ))
You can’t perform that action at this time.
0 commit comments