mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
compat fix for test_field_metadata_custom_mapping in test_dataclasses.py
This commit is contained in:
committed by
Jeong, YunWon
parent
4d05416ce3
commit
6c37e8f4e7
2
Lib/test/test_dataclasses.py
vendored
2
Lib/test/test_dataclasses.py
vendored
@@ -1843,8 +1843,6 @@ class TestCase(unittest.TestCase):
|
||||
'does not support item assignment'):
|
||||
fields(C)[0].metadata['test'] = 3
|
||||
|
||||
# TODO: RUSTPYTHON
|
||||
@unittest.expectedFailure
|
||||
def test_field_metadata_custom_mapping(self):
|
||||
# Try a custom mapping.
|
||||
class SimpleNameSpace:
|
||||
|
||||
@@ -93,13 +93,12 @@ impl Constructor for PyMappingProxy {
|
||||
))]
|
||||
impl PyMappingProxy {
|
||||
fn get_inner(&self, key: PyObjectRef, vm: &VirtualMachine) -> PyResult<Option<PyObjectRef>> {
|
||||
let opt = match &self.mapping {
|
||||
MappingProxyInner::Class(class) => key
|
||||
match &self.mapping {
|
||||
MappingProxyInner::Class(class) => Ok(key
|
||||
.as_interned_str(vm)
|
||||
.and_then(|key| class.attributes.read().get(key).cloned()),
|
||||
MappingProxyInner::Mapping(mapping) => mapping.mapping().subscript(&*key, vm).ok(),
|
||||
};
|
||||
Ok(opt)
|
||||
.and_then(|key| class.attributes.read().get(key).cloned())),
|
||||
MappingProxyInner::Mapping(mapping) => mapping.mapping().subscript(&*key, vm).map(Some),
|
||||
}
|
||||
}
|
||||
|
||||
#[pymethod]
|
||||
|
||||
Reference in New Issue
Block a user