MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / test_default_value

Function test_default_value

src/argparse.rs:591–615  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

589
590 #[test]
591 pub fn test_default_value() {
592 let gil_guard = Python::acquire_gil();
593 let py = gil_guard.python();
594 let mut called = false;
595 let tuple = (0, "foo").to_py_object(py);
596 py_argparse!(py, None, &tuple, None, (x: usize = 42, y: &str = "abc") {
597 assert_eq!(x, 0);
598 assert_eq!(y, "foo");
599 called = true;
600 Ok(())
601 })
602 .unwrap();
603 assert!(called);
604
605 let mut called = false;
606 let tuple = PyTuple::new(py, &[]);
607 py_argparse!(py, None, &tuple, None, (x: usize = 42, y: &str = "abc") {
608 assert_eq!(x, 42);
609 assert_eq!(y, "abc");
610 called = true;
611 Ok(())
612 })
613 .unwrap();
614 assert!(called);
615 }
616}

Callers

nothing calls this directly

Calls 2

pythonMethod · 0.80
to_py_objectMethod · 0.45

Tested by

no test coverage detected