(src: T, expected: &str)
| 724 | use serde::Serialize; |
| 725 | |
| 726 | fn test_ser<T>(src: T, expected: &str) |
| 727 | where |
| 728 | T: Serialize, |
| 729 | { |
| 730 | Python::attach(|py| -> PyResult<()> { |
| 731 | let obj = pythonize(py, &src)?; |
| 732 | |
| 733 | let locals = PyDict::new(py); |
| 734 | locals.set_item("obj", obj)?; |
| 735 | |
| 736 | py.run( |
| 737 | c"import json; result = json.dumps(obj, separators=(',', ':'))", |
| 738 | None, |
| 739 | Some(&locals), |
| 740 | )?; |
| 741 | let result = locals.get_item("result")?.unwrap(); |
| 742 | let result = result.extract::<PyBackedStr>()?; |
| 743 | |
| 744 | assert_eq!(result, expected); |
| 745 | assert_eq!(serde_json::to_string(&src).unwrap(), expected); |
| 746 | |
| 747 | Ok(()) |
| 748 | }) |
| 749 | .unwrap(); |
| 750 | } |
| 751 | |
| 752 | #[test] |
| 753 | fn test_empty_struct() { |
no test coverage detected