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

Function comparisons

tests/test_class.rs:522–536  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

520
521#[test]
522fn comparisons() {
523 let gil = Python::acquire_gil();
524 let py = gil.python();
525
526 let zero = Comparisons::create_instance(py, 0).unwrap();
527 let one = Comparisons::create_instance(py, 1).unwrap();
528 let ten = Comparisons::create_instance(py, 10).unwrap();
529 let minus_one = Comparisons::create_instance(py, -1).unwrap();
530 py_assert!(py, one, "hash(one) == 1");
531 py_assert!(py, ten, "hash(ten) == 10");
532 py_assert!(py, minus_one, "hash(minus_one) == -2");
533
534 py_assert!(py, one, "bool(one) is True");
535 py_assert!(py, zero, "not zero");
536}
537
538py_class!(class Sequence |py| {
539 def __len__(&self) -> PyResult<usize> {

Callers

nothing calls this directly

Calls 1

pythonMethod · 0.80

Tested by

no test coverage detected