From a3efe04dce9d5b4602b40414d3a23516ead85bc0 Mon Sep 17 00:00:00 2001 From: stijn Date: Sat, 4 Oct 2014 08:54:16 +0200 Subject: 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 --- tests/unicode/file1.py | 2 +- tests/unicode/file2.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'tests/unicode') diff --git a/tests/unicode/file1.py b/tests/unicode/file1.py index 554e88674..08b7d2504 100644 --- a/tests/unicode/file1.py +++ b/tests/unicode/file1.py @@ -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)) diff --git a/tests/unicode/file2.py b/tests/unicode/file2.py index aca2e0e0e..b8a341966 100644 --- a/tests/unicode/file2.py +++ b/tests/unicode/file2.py @@ -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)) -- cgit v1.2.3