micropython/tests/io/file_with.py
Damien George 539681fffd tests: Rename test scripts, changing - to _ for consistency.
From now on, all new tests must use underscore.

Addresses issue #727.
2014-07-05 06:14:29 +01:00

22 lines
438 B
Python

f = open("io/data/file1")
with f as f2:
print(f2.read())
# File should be closed
try:
f.read()
except:
# Note: CPython and us throw different exception trying to read from
# close file.
print("can't read file after with")
# Regression test: test that exception in with initialization properly
# thrown and doesn't crash.
try:
with open('__non_existent', 'r'):
pass
except OSError:
print("OSError")