@@ -642,15 +642,17 @@ def test_pass_bytesio_for_reading_and_writing(ext, threads):
642
642
def test_xopen_stdin (monkeypatch , ext , threads ):
643
643
if ext == ".zst" and zstandard is None :
644
644
return
645
- with open (TEST_DIR / f"file.txt{ ext } " , "rt" ) as in_file :
645
+ # Add encoding to suppress encoding warnings
646
+ with open (TEST_DIR / f"file.txt{ ext } " , "rt" , encoding = "latin-1" ) as in_file :
646
647
monkeypatch .setattr ("sys.stdin" , in_file )
647
648
with xopen ("-" , "rt" , threads = threads ) as f :
648
649
data = f .read ()
649
650
assert data == CONTENT
650
651
651
652
652
653
def test_xopen_stdout (monkeypatch ):
653
- with tempfile .TemporaryFile (mode = "w+t" ) as raw :
654
+ # Add encoding to suppress encoding warnings
655
+ with tempfile .TemporaryFile (mode = "w+t" , encoding = "latin-1" ) as raw :
654
656
monkeypatch .setattr ("sys.stdout" , raw )
655
657
with xopen ("-" , "wt" ) as f :
656
658
f .write ("Hello world!" )
@@ -668,6 +670,7 @@ def test_xopen_read_from_pipe(ext, threads):
668
670
with xopen (process .stdout , "rt" , threads = threads ) as f :
669
671
data = f .read ()
670
672
process .wait ()
673
+ process .stdout .close ()
671
674
assert data == CONTENT
672
675
673
676
@@ -685,4 +688,5 @@ def test_xopen_write_to_pipe(threads, ext):
685
688
with xopen (process .stdout , "rt" , threads = threads ) as f :
686
689
data = f .read ()
687
690
process .wait ()
691
+ process .stdout .close ()
688
692
assert data == CONTENT
0 commit comments