mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
20 lines
569 B
Python
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))
|