##// END OF EJS Templates
rust-index: results comparison helper with details...
Georges Racinet -
r52094:52bbb57a default
parent child Browse files
Show More
@@ -13,7 +13,7 b' use crate::{'
13 13 use cpython::{
14 14 buffer::{Element, PyBuffer},
15 15 exc::{IndexError, ValueError},
16 ObjectProtocol, PyBytes, PyClone, PyDict, PyErr, PyInt, PyModule,
16 ObjectProtocol, PyBool, PyBytes, PyClone, PyDict, PyErr, PyInt, PyModule,
17 17 PyObject, PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject,
18 18 };
19 19 use hg::{
@@ -218,10 +218,10 b' py_class!(pub class MixedIndex |py| {'
218 218 def pack_header(&self, *args, **kw) -> PyResult<PyObject> {
219 219 let rindex = self.index(py).borrow();
220 220 let packed = rindex.pack_header(args.get_item(py, 0).extract(py)?);
221 let packed = PyBytes::new(py, &packed);
221 let packed = PyBytes::new(py, &packed).into_object();
222 222 let cpacked = self.call_cindex(py, "pack_header", args, kw)?;
223 assert!(packed.as_object().compare(py, cpacked)?.is_eq());
224 Ok(packed.into_object())
223 assert_py_eq(py, "pack_header", &packed, &cpacked)?;
224 Ok(packed)
225 225 }
226 226
227 227 /// get an index entry
@@ -630,6 +630,27 b' fn nodemap_error(py: Python, err: NodeMa'
630 630 }
631 631 }
632 632
633 fn assert_py_eq(
634 py: Python,
635 method: &str,
636 rust: &PyObject,
637 c: &PyObject,
638 ) -> PyResult<()> {
639 let locals = PyDict::new(py);
640 locals.set_item(py, "rust".into_py_object(py).into_object(), rust)?;
641 locals.set_item(py, "c".into_py_object(py).into_object(), c)?;
642 let is_eq: PyBool =
643 py.eval("rust == c", None, Some(&locals))?.extract(py)?;
644 assert!(
645 is_eq.is_true(),
646 "{} results differ. Rust: {:?} C: {:?}",
647 method,
648 rust,
649 c
650 );
651 Ok(())
652 }
653
633 654 /// Create the module, with __package__ given from parent
634 655 pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> {
635 656 let dotted_name = &format!("{}.revlog", package);
General Comments 0
You need to be logged in to leave comments. Login now