|
2 | 2 |
|
3 | 3 | use pyo3::class::basic::CompareOp; |
4 | 4 | use pyo3::py_run; |
5 | | -use pyo3::types::IntoPyDict; |
6 | 5 | use pyo3::{prelude::*, BoundObject}; |
7 | 6 |
|
8 | 7 | mod test_utils; |
@@ -389,24 +388,6 @@ fn rhs_arithmetic() { |
389 | 388 | }); |
390 | 389 | } |
391 | 390 |
|
392 | | -#[test] |
393 | | -fn rhs_fallback() { |
394 | | - Python::attach(|py| { |
395 | | - let cl = Py::new(py, RhsArithmetic("AR".to_string())).unwrap(); |
396 | | - let cr = Py::new(py, RhsArithmetic("RA".to_string())).unwrap(); |
397 | | - let locals = [("cl", cl), ("cr", cr)].into_py_dict(py).unwrap(); |
398 | | - py_run!(py, locals, "assert cl + cr == 'AR + RA'"); |
399 | | - py_run!(py, locals, "assert cl - cr == 'AR - RA'"); |
400 | | - py_run!(py, locals, "assert cl * cr == 'AR * RA'"); |
401 | | - py_run!(py, locals, "assert cl << cr == 'AR << RA'"); |
402 | | - py_run!(py, locals, "assert cl >> cr == 'AR >> RA'"); |
403 | | - py_run!(py, locals, "assert cl & cr == 'AR & RA'"); |
404 | | - py_run!(py, locals, "assert cl ^ cr == 'AR ^ RA'"); |
405 | | - py_run!(py, locals, "assert cl | cr == 'AR | RA'"); |
406 | | - py_run!(py, locals, "assert cl ** cr == 'AR ** RA (mod: None)'"); |
407 | | - }); |
408 | | -} |
409 | | - |
410 | 391 | #[pyclass] |
411 | 392 | struct LhsAndRhs {} |
412 | 393 |
|
@@ -611,7 +592,12 @@ fn rich_comparisons() { |
611 | 592 | py_run!(py, c, "assert (1 >= c) == 'RC <= 1'"); |
612 | 593 |
|
613 | 594 | // Ensure that passing a wrong self type from Python does not cause UB |
614 | | - py_expect_exception!(py, c, "type(c).__richcmp__(object(), 1)", PyTypeError); |
| 595 | + py_expect_exception!(py, c, "type(c).__lt__(object(), 1)", PyTypeError); |
| 596 | + py_expect_exception!(py, c, "type(c).__le__(object(), 1)", PyTypeError); |
| 597 | + py_expect_exception!(py, c, "type(c).__eq__(object(), 1)", PyTypeError); |
| 598 | + py_expect_exception!(py, c, "type(c).__ne__(object(), 1)", PyTypeError); |
| 599 | + py_expect_exception!(py, c, "type(c).__gt__(object(), 1)", PyTypeError); |
| 600 | + py_expect_exception!(py, c, "type(c).__ge__(object(), 1)", PyTypeError); |
615 | 601 | }); |
616 | 602 | } |
617 | 603 |
|
|
0 commit comments