mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +09:00
os: Fix error message of fspath
This commit is contained in:
@@ -3681,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'):
|
||||
|
||||
@@ -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,
|
||||
))
|
||||
|
||||
Reference in New Issue
Block a user