MCPcopy Create free account
hub / github.com/davidhewitt/pythonize / test_option_none_round_trip

Function test_option_none_round_trip

tests/test_structs.rs:180–194  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178
179#[test]
180fn test_option_none_round_trip() {
181 Python::attach(|py| {
182 let original = WithOption {
183 label: "x".into(),
184 count: None,
185 };
186 let py_obj = pythonize(py, &original).unwrap();
187 let dict = py_obj.cast::<PyDict>().unwrap();
188 let count_opt = dict.get_item("count").unwrap();
189 assert!(count_opt.is_some());
190 assert!(count_opt.unwrap().is_none());
191 let result: WithOption = depythonize(&py_obj).unwrap();
192 assert_eq!(result, original);
193 });
194}
195
196// --- Option<T> Some ---
197

Callers

nothing calls this directly

Calls 2

pythonizeFunction · 0.85
depythonizeFunction · 0.85

Tested by

no test coverage detected