Merge pull request #2706 from deantvv/os-fix-test

Fix tests in os
This commit is contained in:
Jeong YunWon
2021-06-15 19:55:01 +09:00
committed by GitHub
2 changed files with 3 additions and 7 deletions

View File

@@ -3630,15 +3630,13 @@ class PathTConverterTests(unittest.TestCase):
# function, cleanup function)
functions = [
('stat', True, (), None),
('lstat', False, (), None),
('lstat', True, (), None),
('access', False, (os.F_OK,), None),
('chflags', False, (0,), None),
('lchflags', False, (0,), None),
('open', False, (0,), getattr(os, 'close', None)),
]
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_path_t_converter(self):
str_filename = support.TESTFN
if os.name == 'nt':
@@ -3683,8 +3681,6 @@ class PathTConverterTests(unittest.TestCase):
'os.PathLike'):
fn(fd, *extra_args)
# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_path_t_converter_and_custom_class(self):
msg = r'__fspath__\(\) to return str or bytes, not %s'
with self.assertRaisesRegex(TypeError, msg % r'int'):

View File

@@ -158,14 +158,14 @@ fn fspath(obj: PyObjectRef, check_for_nul: bool, vm: &VirtualMachine) -> PyResul
}
let method = vm.get_method_or_type_error(obj.clone(), "__fspath__", || {
format!(
"expected str, bytes or os.PathLike object, not '{}'",
"expected str, bytes or os.PathLike object, not {}",
obj.class().name
)
})?;
let result = vm.invoke(&method, ())?;
match1(&result)?.ok_or_else(|| {
vm.new_type_error(format!(
"expected {}.__fspath__() to return str or bytes, not '{}'",
"expected {}.__fspath__() to return str or bytes, not {}",
obj.class().name,
result.class().name,
))