module-policy: update rust extension import to use the new module policy
authorRaphaël Gomès <rgomes@octobus.net>
Tue, 23 Jul 2019 11:12:36 +0200
changeset 42670 a7f1a0b3f461
parent 42669 36c692eb28d3
child 42671 e77be7e2109f
module-policy: update rust extension import to use the new module policy Differential Revision: https://phab.mercurial-scm.org/D6677
tests/test-rust-discovery.py
--- a/tests/test-rust-discovery.py	Sun Jul 21 07:59:16 2019 -0700
+++ b/tests/test-rust-discovery.py	Tue Jul 23 11:12:36 2019 +0200
@@ -1,16 +1,9 @@
 from __future__ import absolute_import
 import unittest
 
-try:
-    from mercurial import rustext
-    rustext.__name__  # trigger immediate actual import
-except ImportError:
-    rustext = None
-else:
-    # this would fail already without appropriate ancestor.__package__
-    from mercurial.rustext.discovery import (
-        PartialDiscovery,
-    )
+from mercurial import policy
+
+PartialDiscovery = policy.importrust('discovery', member='PartialDiscovery')
 
 try:
     from mercurial.cext import parsers as cparsers
@@ -39,7 +32,7 @@
     )
 
 
-@unittest.skipIf(rustext is None or cparsers is None,
+@unittest.skipIf(PartialDiscovery is None or cparsers is None,
                  "rustext or the C Extension parsers module "
                  "discovery relies on is not available")
 class rustdiscoverytest(unittest.TestCase):