Skip to content

Commit 8bb7bd8

Browse files
author
hauntsaninja
committed
update tests
1 parent 12ce2dd commit 8bb7bd8

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

test-data/stdlib-samples/3.2/test/test_base64.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ def test_encode_file(self) -> None:
248248
output = self.get_output('-e', support.TESTFN)
249249
self.assertEqual(output.rstrip(), b'Yf9iCg==')
250250

251-
with open(support.TESTFN, 'rb') as fp:
252-
output = self.get_output('-e', stdin=fp)
251+
with open(support.TESTFN, 'rb') as fp2:
252+
output = self.get_output('-e', stdin=fp2)
253253
self.assertEqual(output.rstrip(), b'Yf9iCg==')
254254

255255
def test_decode(self) -> None:

test-data/stdlib-samples/3.2/test/test_genericpath.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,26 +114,21 @@ def test_getsize(self) -> None:
114114
support.unlink(support.TESTFN)
115115

116116
def test_time(self) -> None:
117-
f = open(support.TESTFN, "wb")
118-
try:
119-
f.write(b"foo")
120-
f.close()
121-
f = open(support.TESTFN, "ab")
122-
f.write(b"bar")
123-
f.close()
124-
f = open(support.TESTFN, "rb")
125-
d = f.read()
126-
f.close()
127-
self.assertEqual(d, b"foobar")
128-
129-
self.assertLessEqual(
130-
self.pathmodule.getctime(support.TESTFN),
131-
self.pathmodule.getmtime(support.TESTFN)
132-
)
133-
finally:
134-
if not f.closed:
135-
f.close()
136-
support.unlink(support.TESTFN)
117+
f1 = open(support.TESTFN, "wb")
118+
f1.write(b"foo")
119+
f1.close()
120+
f2 = open(support.TESTFN, "ab")
121+
f2.write(b"bar")
122+
f2.close()
123+
f3 = open(support.TESTFN, "rb")
124+
d = f3.read()
125+
f3.close()
126+
self.assertEqual(d, b"foobar")
127+
128+
self.assertLessEqual(
129+
self.pathmodule.getctime(support.TESTFN),
130+
self.pathmodule.getmtime(support.TESTFN)
131+
)
137132

138133
def test_exists(self) -> None:
139134
self.assertIs(self.pathmodule.exists(support.TESTFN), False)

test-data/unit/pythoneval.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,8 @@ f.write('x')
271271
f.write(b'x')
272272
f.foobar()
273273
[out]
274-
_program.py:3: error: Argument 1 to "write" of "IO" has incompatible type "bytes"; expected "str"
275-
_program.py:4: error: "TextIO" has no attribute "foobar"
274+
_program.py:3: error: Argument 1 to "write" of "TextIOBase" has incompatible type "bytes"; expected "str"
275+
_program.py:4: error: "TextIOWrapper" has no attribute "foobar"
276276

277277
[case testOpenReturnTypeInference]
278278
reveal_type(open('x'))
@@ -281,9 +281,9 @@ reveal_type(open('x', 'rb'))
281281
mode = 'rb'
282282
reveal_type(open('x', mode))
283283
[out]
284-
_program.py:1: note: Revealed type is 'typing.TextIO'
285-
_program.py:2: note: Revealed type is 'typing.TextIO'
286-
_program.py:3: note: Revealed type is 'typing.BinaryIO'
284+
_program.py:1: note: Revealed type is 'io.TextIOWrapper'
285+
_program.py:2: note: Revealed type is 'io.TextIOWrapper'
286+
_program.py:3: note: Revealed type is 'io.BufferedReader'
287287
_program.py:5: note: Revealed type is 'typing.IO[Any]'
288288

289289
[case testOpenReturnTypeInferenceSpecialCases]
@@ -292,8 +292,8 @@ reveal_type(open(file='x', mode='rb'))
292292
mode = 'rb'
293293
reveal_type(open(mode=mode, file='r'))
294294
[out]
295-
_testOpenReturnTypeInferenceSpecialCases.py:1: note: Revealed type is 'typing.BinaryIO'
296-
_testOpenReturnTypeInferenceSpecialCases.py:2: note: Revealed type is 'typing.BinaryIO'
295+
_testOpenReturnTypeInferenceSpecialCases.py:1: note: Revealed type is 'io.BufferedReader'
296+
_testOpenReturnTypeInferenceSpecialCases.py:2: note: Revealed type is 'io.BufferedReader'
297297
_testOpenReturnTypeInferenceSpecialCases.py:4: note: Revealed type is 'typing.IO[Any]'
298298

299299
[case testPathOpenReturnTypeInference]

0 commit comments

Comments
 (0)