Improve test coverage of os.open

This commit is contained in:
Tom Forbes
2019-02-04 10:32:17 +00:00
parent 4d02a1e037
commit 6c18126382
3 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
fd = open('README.md')
assert 'RustPython' in fd.read()
try:
open('DoesNotExist')
assert False
except FileNotFoundError:
pass

View File

@@ -2,3 +2,9 @@ import os
assert os.open('README.md', 0) > 0
try:
os.open('DOES_NOT_EXIST', 0)
assert False
except FileNotFoundError:
pass

View File

@@ -767,6 +767,11 @@ pub fn make_module(ctx: &PyContext) -> PyObjectRef {
ctx.set_attr(&py_mod, "ValueError", ctx.exceptions.value_error.clone());
ctx.set_attr(&py_mod, "IndexError", ctx.exceptions.index_error.clone());
ctx.set_attr(&py_mod, "ImportError", ctx.exceptions.import_error.clone());
ctx.set_attr(
&py_mod,
"FileNotFoundError",
ctx.exceptions.file_not_found_error.clone(),
);
ctx.set_attr(
&py_mod,
"StopIteration",