Skip to content

Commit 9c6ab6c

Browse files
committed
Enable some test_io tests
1 parent 95e3048 commit 9c6ab6c

File tree

2 files changed

+118
-2
lines changed

2 files changed

+118
-2
lines changed

Src/IronPythonTest/Cases/CPythonCasesManifest.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,8 @@ Ignore=true
508508
Ignore=true
509509
Reason=ImportError: No module named _multiprocessing
510510

511-
[CPython.test_io]
511+
[CPython.test_io] # IronPython.test_io_stdlib
512512
Ignore=true
513-
Reason=StackOverflowException
514513

515514
[CPython.test_ioctl]
516515
RunCondition=$(IS_POSIX)

Tests/test_io_stdlib.py

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# Licensed to the .NET Foundation under one or more agreements.
2+
# The .NET Foundation licenses this file to you under the Apache 2.0 License.
3+
# See the LICENSE file in the project root for more information.
4+
5+
##
6+
## Run selected tests from test_io from StdLib
7+
##
8+
9+
from iptest import is_ironpython, generate_suite, run_test
10+
11+
import test.test_io
12+
13+
def load_tests(loader, standard_tests, pattern):
14+
tests = loader.loadTestsFromModule(test.test_io)
15+
16+
if is_ironpython:
17+
failing_tests = [
18+
test.test_io.CIOTest('test_BufferedIOBase_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
19+
test.test_io.CIOTest('test_IOBase_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
20+
test.test_io.CIOTest('test_RawIOBase_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
21+
test.test_io.CIOTest('test_RawIOBase_read'), # TypeError: expected int, got NoneType
22+
test.test_io.CIOTest('test_TextIOBase_destructor'), # AssertionError: Lists differ: [1, 2, 3, 2] != [1, 2, 3]
23+
test.test_io.CIOTest('test_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
24+
test.test_io.CIOTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
25+
test.test_io.CIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
26+
test.test_io.CIOTest('test_invalid_operations'), # OSError: can't do nonzero cur-relative seeks
27+
test.test_io.CIOTest('test_open_handles_NUL_chars'), # ValueError: Illegal characters in path.
28+
test.test_io.PyIOTest('test_destructor'), # AssertionError: Lists differ: [2, 3, 1, 2] != [1, 2, 3]
29+
test.test_io.PyIOTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
30+
test.test_io.PyIOTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
31+
test.test_io.PyIOTest('test_open_handles_NUL_chars'), # ValueError: Illegal characters in path.
32+
test.test_io.CBufferedReaderTest('test_args_error'), # AssertionError: "BufferedReader" does not match "__init__() takes at most 2 arguments (4 given)"
33+
test.test_io.CBufferedReaderTest('test_buffering'), # TypeError: BufferedReader() takes at least 0 arguments (2 given)
34+
test.test_io.CBufferedReaderTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
35+
test.test_io.CBufferedReaderTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
36+
test.test_io.CBufferedReaderTest('test_initialization'), # AssertionError: ValueError not raised by read
37+
test.test_io.CBufferedReaderTest('test_misbehaved_io_read'), # AssertionError: OSError not raised by read
38+
test.test_io.CBufferedReaderTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
39+
test.test_io.CBufferedReaderTest('test_override_destructor'), # AssertionError: Lists differ: [1, 2, 3, 2] != [1, 2, 3]
40+
test.test_io.CBufferedReaderTest('test_read_non_blocking'), # AssertionError: b'' is not None
41+
test.test_io.CBufferedReaderTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
42+
test.test_io.CBufferedReaderTest('test_readonly_attributes'), # AssertionError: AttributeError not raised
43+
test.test_io.CBufferedReaderTest('test_uninitialized'), # AssertionError: (<class 'ValueError'>, <class 'AttributeError'>) not raised by read
44+
test.test_io.PyBufferedReaderTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
45+
test.test_io.PyBufferedReaderTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
46+
test.test_io.CBufferedWriterTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
47+
test.test_io.CBufferedWriterTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
48+
test.test_io.CBufferedWriterTest('test_initialization'), # AssertionError: ValueError not raised by write
49+
test.test_io.CBufferedWriterTest('test_max_buffer_size_removal'), # AssertionError: TypeError not raised
50+
test.test_io.CBufferedWriterTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
51+
test.test_io.CBufferedWriterTest('test_readonly_attributes'), # AssertionError: AttributeError not raised
52+
test.test_io.CBufferedWriterTest('test_uninitialized'), # TypeError: BufferedWriter() takes at least 1 argument (0 given)
53+
test.test_io.CBufferedWriterTest('test_write_error_on_close'), # AssertionError: OSError not raised by close
54+
test.test_io.CBufferedWriterTest('test_write_non_blocking'), # TypeError: expected int, got NoneType
55+
test.test_io.PyBufferedWriterTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
56+
test.test_io.CBufferedRWPairTest('test_constructor_max_buffer_size_removal'), # AssertionError: TypeError not raised
57+
test.test_io.CBufferedRWPairTest('test_reader_writer_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
58+
test.test_io.CBufferedRWPairTest('test_uninitialized'), # TypeError: BufferedRWPair() takes at least 2 arguments (0 given)
59+
test.test_io.PyBufferedRWPairTest('test_reader_writer_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
60+
test.test_io.CBufferedRandomTest('test_close_error_on_close'), # AssertionError: None is not an instance of <class 'OSError'>
61+
test.test_io.CBufferedRandomTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
62+
test.test_io.CBufferedRandomTest('test_max_buffer_size_removal'), # AssertionError: TypeError not raised
63+
test.test_io.CBufferedRandomTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
64+
test.test_io.CBufferedRandomTest('test_read_non_blocking'), # AssertionError: b'' is not None
65+
test.test_io.CBufferedRandomTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
66+
test.test_io.CBufferedRandomTest('test_readonly_attributes'), # AssertionError: AttributeError not raised
67+
test.test_io.CBufferedRandomTest('test_repr'), # AssertionError: '<BufferedRandom object at 0x000000000000003A>' != '<_io.BufferedRandom>'
68+
test.test_io.CBufferedRandomTest('test_uninitialized'), # TypeError: BufferedRandom() takes at least 1 argument (0 given)
69+
test.test_io.CBufferedRandomTest('test_write_error_on_close'), # AssertionError: OSError not raised by close
70+
test.test_io.CBufferedRandomTest('test_write_non_blocking'), # TypeError: expected int, got NoneType
71+
test.test_io.PyBufferedRandomTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
72+
test.test_io.PyBufferedRandomTest('test_read_on_closed'), # AssertionError: ValueError not raised by read1
73+
test.test_io.CTextIOWrapperTest('test_append_bom'), # AssertionError: b'\xef\xbb\xbfaaa\xef\xbb\xbfxxx' != b'\xef\xbb\xbfaaaxxx'
74+
test.test_io.CTextIOWrapperTest('test_close_error_on_close'), # AssertionError: OSError not raised
75+
test.test_io.CTextIOWrapperTest('test_encoded_writes'), # UnicodeEncodeError
76+
test.test_io.CTextIOWrapperTest('test_flush_error_on_close'), # AssertionError: OSError not raised by close
77+
test.test_io.CTextIOWrapperTest('test_garbage_collection'), # AssertionError: filter ('', ResourceWarning) did not catch any warning
78+
test.test_io.CTextIOWrapperTest('test_initialization'), # AssertionError: ValueError not raised by read
79+
test.test_io.CTextIOWrapperTest('test_non_text_encoding_codecs_are_rejected'), # AssertionError: LookupError not raised
80+
test.test_io.CTextIOWrapperTest('test_nonnormalized_close_error_on_close'), # AssertionError: NameError not raised
81+
test.test_io.CTextIOWrapperTest('test_rawio'), # AttributeError: 'CMockRawIO' object has no attribute 'read1'
82+
test.test_io.CTextIOWrapperTest('test_read_nonbytes'), # AttributeError: 'StringIO' object has no attribute 'read1'
83+
test.test_io.CTextIOWrapperTest('test_seek_append_bom'), # OSError: [Errno -2146232800] Unable seek backward to overwrite data that previously existed in a file opened in Append mode.
84+
test.test_io.CTextIOWrapperTest('test_seek_bom'), # AssertionError: b'\xef\xbb\xbfbbb\xef\xbb\xbfzzz' != b'\xef\xbb\xbfbbbzzz'
85+
test.test_io.CTextIOWrapperTest('test_uninitialized'), # AssertionError: Exception not raised by repr
86+
test.test_io.CTextIOWrapperTest('test_unseekable'), # OSError: underlying stream is not seekable
87+
test.test_io.PyTextIOWrapperTest('test_nonnormalized_close_error_on_close'), # AssertionError: None is not an instance of <class 'NameError'>
88+
test.test_io.PyTextIOWrapperTest('test_seek_append_bom'), # OSError: [Errno -2146232800] Unable seek backward to overwrite data that previously existed in a file opened in Append mode.
89+
test.test_io.CMiscIOTest('test_io_after_close'), # AttributeError: 'TextIOWrapper' object has no attribute 'read1'
90+
test.test_io.CMiscIOTest('test_pickling'), # AssertionError: TypeError not raised by _dumps
91+
test.test_io.CMiscIOTest('test_readinto_buffer_overflow'), # IndexError: Index was outside the bounds of the array.
92+
test.test_io.CMiscIOTest('test_warn_on_dealloc'), # AssertionError: ResourceWarning not triggered
93+
test.test_io.CMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered
94+
test.test_io.PyMiscIOTest('test_io_after_close'), # AttributeError: 'FileIO' object has no attribute 'read1'
95+
test.test_io.PyMiscIOTest('test_pickling'), # AssertionError: TypeError not raised by _dumps
96+
test.test_io.PyMiscIOTest('test_warn_on_dealloc'), # AssertionError: ResourceWarning not triggered
97+
test.test_io.PyMiscIOTest('test_warn_on_dealloc_fd'), # AssertionError: ResourceWarning not triggered
98+
]
99+
100+
skip_tests = [
101+
test.test_io.CBufferedWriterTest('test_override_destructor'), # StackOverflowException
102+
test.test_io.CBufferedRandomTest('test_override_destructor'), # StackOverflowException
103+
test.test_io.CTextIOWrapperTest('test_bufio_write_through'), # StackOverflowException
104+
test.test_io.CTextIOWrapperTest('test_override_destructor'), # StackOverflowException
105+
106+
# failure prevents files from closing
107+
test.test_io.CTextIOWrapperTest('test_seek_and_tell'), # TypeError: NoneType is not callable
108+
test.test_io.CMiscIOTest('test_attributes'), # AssertionError: 'r' != 'U'
109+
test.test_io.PyMiscIOTest('test_attributes'), # AssertionError: 'wb+' != 'rb+'
110+
]
111+
112+
return generate_suite(tests, failing_tests, skip_tests)
113+
114+
else:
115+
return tests
116+
117+
run_test(__name__)

0 commit comments

Comments
 (0)