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

Function number_extensions

tests/test_class.rs:1406–1424  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1404
1405#[test]
1406fn number_extensions() {
1407 let gil = Python::acquire_gil();
1408 let py = gil.python();
1409
1410 let c = NumberExt::create_instance(py).unwrap();
1411 py_run!(py, c, "assert c % 1 == 'BA % 1'");
1412 py_run!(py, c, "assert 1 % c == '1 % BA'");
1413 py_run!(py, c, "assert divmod(c,1) == 'divmod(BA,1)'");
1414 py_run!(py, c, "assert divmod(1,c) == 'divmod(1,BA)'");
1415
1416 py_run!(py, c, "assert c**c == 'pow(BA,BA,None)'");
1417 py_run!(py, c, "assert c**1 == 'pow(BA,1,None)'");
1418 py_run!(py, c, "assert 1**c == 'pow(1,BA,None)'");
1419 py_run!(py, c, "assert pow(c,c,2) == 'pow(BA,BA,2)'");
1420 py_run!(py, c, "assert pow(c,1,2) == 'pow(BA,1,2)'");
1421 py_run!(py, c, "assert pow(1,c,2) == 'pow(1,BA,2)'");
1422
1423 py_run!(py, c, "import operator; assert operator.index(c) == 69");
1424}
1425
1426#[cfg(feature = "python3-sys")]
1427py_class!(class Py3Number |py| {

Callers

nothing calls this directly

Calls 1

pythonMethod · 0.80

Tested by

no test coverage detected