Files
RustPython/extra_tests/snippets/builtin_open.py
Rex Ledesma 4e2e0b41c6 chore: add ruff format --check (#5774)
* chore: add `ruff format --check`

* fix tests
2025-05-12 14:20:01 +09:00

20 lines
569 B
Python

from testutils import assert_raises
fd = open("README.md")
assert "RustPython" in fd.read()
assert_raises(FileNotFoundError, open, "DoesNotExist")
# Use open as a context manager
with open("README.md", "rt") as fp:
contents = fp.read()
assert type(contents) == str, "type is " + str(type(contents))
with open("README.md", "r") as fp:
contents = fp.read()
assert type(contents) == str, "type is " + str(type(contents))
with open("README.md", "rb") as fp:
contents = fp.read()
assert type(contents) == bytes, "type is " + str(type(contents))