changeset 40968:74f41329bf55

rust-cpython: testing the bindings from Python This is easier and more convincing than doing the same tests from a Rust tests module. Differential Revision: https://phab.mercurial-scm.org/D5437
author Georges Racinet <gracinet@anybox.fr>
date Tue, 16 Oct 2018 19:58:27 +0200
parents 462a26756f70
children 55fcdb73c88b
files tests/test-rust-ancestor.py
diffstat 1 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-rust-ancestor.py	Tue Oct 16 19:58:27 2018 +0200
@@ -0,0 +1,39 @@
+from __future__ import absolute_import
+import unittest
+
+try:
+    from mercurial import rustext
+except ImportError:
+    rustext = None
+
+try:
+    from mercurial.cext import parsers as cparsers
+except ImportError:
+    cparsers = None
+
+@unittest.skipIf(rustext is None or cparsers is None,
+                 "rustext.ancestor or the C Extension parsers module "
+                 "it relies on is not available")
+class rustancestorstest(unittest.TestCase):
+    """Test the correctness of binding to Rust code.
+
+    This test is merely for the binding to Rust itself: extraction of
+    Python variable, giving back the results etc.
+
+    It is not meant to test the algorithmic correctness of the operations
+    on ancestors it provides. Hence the very simple embedded index data is
+    good enough.
+
+    Algorithmic correctness is asserted by the Rust unit tests.
+    """
+
+    def testmodule(self):
+        self.assertTrue('DAG' in rustext.ancestor.__doc__)
+
+    def testgrapherror(self):
+        self.assertTrue('GraphError' in dir(rustext))
+
+
+if __name__ == '__main__':
+    import silenttestrunner
+    silenttestrunner.main(__name__)