diff options
author | stijn <stinos@zoho.com> | 2014-10-04 08:54:16 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-10-21 22:10:38 +0300 |
commit | a3efe04dce9d5b4602b40414d3a23516ead85bc0 (patch) | |
tree | a51f3513a5ce16cfe3bc75bf4bf00dae5af55528 | |
parent | 2fe4cf7761ffc40d81b4780d59c2b6ef0a5c16ff (diff) | |
download | micropython-a3efe04dce9d5b4602b40414d3a23516ead85bc0.tar.gz micropython-a3efe04dce9d5b4602b40414d3a23516ead85bc0.zip |
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
-rw-r--r-- | tests/io/file1.py | 8 | ||||
-rw-r--r-- | tests/unicode/file1.py | 2 | ||||
-rw-r--r-- | tests/unicode/file2.py | 6 |
3 files changed, 14 insertions, 2 deletions
diff --git a/tests/io/file1.py b/tests/io/file1.py index 7d5154a4f8..c46c081b80 100644 --- a/tests/io/file1.py +++ b/tests/io/file1.py @@ -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()) diff --git a/tests/unicode/file1.py b/tests/unicode/file1.py index 554e886743..08b7d25041 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 aca2e0e0ed..b8a3419660 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)) |