Use mode/encoding kwargs in io and unicode tests
mode argument is used to assert it works encoding argument is used to make sure CPython uses the correct encoding as it does not automatically use utf-8
This commit is contained in:
parent
2fe4cf7761
commit
a3efe04dce
|
@ -4,3 +4,11 @@ print(f.readline())
|
|||
print(f.read())
|
||||
f = open("io/data/file1")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1","r")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1","rb")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1",mode="r")
|
||||
print(f.readlines())
|
||||
f = open("io/data/file1",mode="rb")
|
||||
print(f.readlines())
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
f = open("unicode/data/utf-8_1.txt")
|
||||
f = open("unicode/data/utf-8_1.txt", encoding="utf-8")
|
||||
l = f.readline()
|
||||
print(l)
|
||||
print(len(l))
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
# test reading a given number of characters
|
||||
|
||||
def do(mode):
|
||||
f = open('unicode/data/utf-8_2.txt', mode)
|
||||
if mode == 'rb':
|
||||
enc = None
|
||||
else:
|
||||
enc = 'utf-8'
|
||||
f = open('unicode/data/utf-8_2.txt', mode=mode, encoding=enc)
|
||||
print(f.read(1))
|
||||
print(f.read(1))
|
||||
print(f.read(2))
|
||||
|
|
Loading…
Reference in New Issue