bpo-40275: Use new test.support helper submodules in tests (GH-21314)

This commit is contained in:
Hai Shi 2020-07-06 17:12:49 +08:00 committed by GitHub
parent 9ce8132e1f
commit 883bc63833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 225 additions and 194 deletions

View file

@ -1,5 +1,6 @@
import unittest
from test import support
from test.support import os_helper
import io # C implementation.
import _pyio as pyio # Python implementation.
@ -17,18 +18,18 @@ class BufferSizeTest:
# .readline()s deliver what we wrote.
# Ensure we can open TESTFN for writing.
support.unlink(support.TESTFN)
os_helper.unlink(os_helper.TESTFN)
# Since C doesn't guarantee we can write/read arbitrary bytes in text
# files, use binary mode.
f = self.open(support.TESTFN, "wb")
f = self.open(os_helper.TESTFN, "wb")
try:
# write once with \n and once without
f.write(s)
f.write(b"\n")
f.write(s)
f.close()
f = open(support.TESTFN, "rb")
f = open(os_helper.TESTFN, "rb")
line = f.readline()
self.assertEqual(line, s + b"\n")
line = f.readline()
@ -37,7 +38,7 @@ class BufferSizeTest:
self.assertFalse(line) # Must be at EOF
f.close()
finally:
support.unlink(support.TESTFN)
os_helper.unlink(os_helper.TESTFN)
def drive_one(self, pattern):
for length in lengths: