8000 Make use of TESTFN_ASCII in test_fileio by zware · Pull Request #101645 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Make use of TESTFN_ASCII in test_fileio #101645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions Lib/test/test_fileio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
from test.support import (
cpython_only, swap_attr, gc_collect, is_emscripten, is_wasi
)
from test.support.os_helper import (TESTFN, TESTFN_UNICODE, make_bad_fd)
from test.support.os_helper import (
TESTFN, TESTFN_ASCII, TESTFN_UNICODE, make_bad_fd,
)
from test.support.warnings_helper import check_warnings
from collections import UserList

Expand Down Expand Up @@ -431,18 +433,15 @@ def testUnicodeOpen(self):

def testBytesOpen(self):
# Opening a bytes filename
try:
fn = TESTFN.encode("ascii")
except UnicodeEncodeError:
self.skipTest('could not encode %r to ascii' % TESTFN)
fn = TESTFN_ASCII.encode("ascii")
f = self.FileIO(fn, "w")
try:
f.write(b"abc")
f.close()
with open(TESTFN, "rb") as f:
with open(TESTFN_ASCII, "rb") as f:
self.assertEqual(f.read(), b"abc")
finally:
os.unlink(TESTFN)
os.unlink(TESTFN_ASCII)

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