8000 [3.11] Make use of TESTFN_ASCII in test_fileio (GH-101645) (#101650) · python/cpython@c38b4e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c38b4e7

Browse files
[3.11] Make use of TESTFN_ASCII in test_fileio (GH-101645) (#101650)
testBytesOpen requires an ASCII filename, but TESTFN usually isn't ASCII. (cherry picked from commit 6fd5eb6) Co-authored-by: Zachary Ware <zach@python.org>
1 parent 7240ba7 commit c38b4e7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Lib/test/test_fileio.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
from test.support import (
1313
cpython_only, swap_attr, gc_collect, is_emscripten, is_wasi
1414
)
15-
from test.support.os_helper import (TESTFN, TESTFN_UNICODE, make_bad_fd)
15+
from test.support.os_helper import (
16+
TESTFN, TESTFN_ASCII, TESTFN_UNICODE, make_bad_fd,
17+
)
1618
from test.support.warnings_helper import check_warnings
1719
from collections import UserList
1820

@@ -431,18 +433,15 @@ def testUnicodeOpen(self):
431433

432434
def testBytesOpen(self):
433435
# Opening a bytes filename
434-
try:
435-
fn = TESTFN.encode("ascii")
436-
except UnicodeEncodeError:
437-
self.skipTest('could not encode %r to ascii' % TESTFN)
436+
fn = TESTFN_ASCII.encode("ascii")
438437
f = 7B95 self.FileIO(fn, "w")
439438
try:
440439
f.write(b"abc")
441440
f.close()
442-
with open(TESTFN, "rb") as f:
441+
with open(TESTFN_ASCII, "rb") as f:
443442
self.assertEqual(f.read(), b"abc")
444443
finally:
445-
os.unlink(TESTFN)
444+
os.unlink(TESTFN_ASCII)
446445

447446
@unittest.skipIf(sys.getfilesystemencoding() != 'utf-8',
448447
"test only works for utf-8 filesystems")

0 commit comments

Comments
 (0)
0