diff tests/test-rust-ancestor.py @ 52413:20fe0bf9a9a5

rust-pyo3: dagop submodule implementation This is the first demonstration that the passing of objects through the Python interpreter from `rustext` to `pyo3_rustext` actually works. In the Python tests, we conflate the presence of the `pyo3_rustext` package with that of `rustext`, as we do not plan to support building one and not the other (we hope to convert fully to PyO3 soon). The skipping is actually done by the base test class. The implementation of `rank` is as trivial as it was in `hg-cpython`, yet it required to be able to convert exceptions from `vcsgraph`.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Sat, 30 Nov 2024 20:58:09 +0100
parents cf5b47b885b1
children 3ffcdbf0b432
line wrap: on
line diff
--- a/tests/test-rust-ancestor.py	Thu Dec 05 14:36:40 2024 +0100
+++ b/tests/test-rust-ancestor.py	Sat Nov 30 20:58:09 2024 +0100
@@ -5,11 +5,12 @@
 from mercurial.testing import revlog as revlogtesting
 
 try:
-    from mercurial import rustext
+    from mercurial import pyo3_rustext, rustext
 
     rustext.__name__  # trigger immediate actual import
+    pyo3_rustext.__name__
 except ImportError:
-    rustext = None
+    rustext = pyo3_rustext = None
 else:
     # this would fail already without appropriate ancestor.__package__
     from mercurial.rustext.ancestor import (
@@ -148,6 +149,17 @@
         idx = self.parserustindex()
         self.assertEqual(dagop.headrevs(idx, [1, 2, 3]), {3})
 
+    def testpyo3_headrevs(self):
+        idx = self.parserustindex()
+        self.assertEqual(pyo3_rustext.dagop.headrevs(idx, [1, 2, 3]), {3})
+
+    def testpyo3_rank(self):
+        idx = self.parserustindex()
+        try:
+            pyo3_rustext.dagop.rank(idx, 1, 2)
+        except pyo3_rustext.GraphError as exc:
+            self.assertEqual(exc.args, ("InconsistentGraphData",))
+
 
 if __name__ == '__main__':
     import silenttestrunner