mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
Improve test coverage of os.open
This commit is contained in:
8
tests/snippets/builtin_open.py
Normal file
8
tests/snippets/builtin_open.py
Normal file
@@ -0,0 +1,8 @@
|
||||
fd = open('README.md')
|
||||
assert 'RustPython' in fd.read()
|
||||
|
||||
try:
|
||||
open('DoesNotExist')
|
||||
assert False
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user