MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_07

Function test_07

extra_tests/snippets/stdlib_io_bytesio.py:77–98  ·  view source on GitHub ↗

Tests that flush() returns None when the file is open, and raises ValueError when the file is closed. CPython reference: Modules/_io/bytesio.c:325-335

()

Source from the content-addressed store, hash-verified

75
76
77def test_07():
78 """
79 Tests that flush() returns None when the file is open,
80 and raises ValueError when the file is closed.
81 CPython reference: Modules/_io/bytesio.c:325-335
82 """
83 f = BytesIO(b"Test String 7")
84
85 # flush() on an open BytesIO returns None
86 assert f.flush() is None
87
88 # flush() is defined directly on BytesIO (not just inherited)
89 assert "flush" in BytesIO.__dict__
90
91 f.close()
92
93 # flush() on a closed BytesIO raises ValueError
94 try:
95 f.flush()
96 assert False, "Expected ValueError not raised"
97 except ValueError:
98 pass
99
100
101if __name__ == "__main__":

Callers 1

Calls 3

closeMethod · 0.95
BytesIOClass · 0.90
flushMethod · 0.45

Tested by

no test coverage detected