File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 3
3
"""
4
4
import bz2
5
5
import sys
6
+ import tempfile
6
7
from contextlib import contextmanager
7
8
import functools
8
9
import gzip
@@ -634,3 +635,21 @@ def test_pass_bytesio_for_reading_and_writing(ext, threads):
634
635
filelike .seek (0 )
635
636
with xopen (filelike , "rb" , format = format , threads = threads ) as fh :
636
637
assert fh .readline () == first_line
638
+
639
+
640
+ def test_xopen_stdin (monkeypatch ):
641
+ with open (TEST_DIR / "file.txt" ) as in_file :
642
+ monkeypatch .setattr ("sys.stdin" , in_file )
643
+ with xopen ("-" , "rt" ) as f :
644
+ data = f .read ()
645
+ assert data == CONTENT
646
+
647
+
648
+ def test_xopen_stdout (monkeypatch ):
649
+ with tempfile .TemporaryFile (mode = "w+t" ) as raw :
650
+ monkeypatch .setattr ("sys.stdout" , raw )
651
+ with xopen ("-" , "wt" ) as f :
652
+ f .write ("Hello world!" )
653
+ raw .seek (0 )
654
+ data = raw .read ()
655
+ assert data == "Hello world!"
You can’t perform that action at this time.
0 commit comments