Patchwork [2,of,7] tests: import mercurial modules by name in test-propertycache

login
register
mail settings
Submitter Yuya Nishihara
Date April 9, 2016, 10:56 a.m.
Message ID <e32c0ef0b7631ac4f2b6.1460199374@mimosa>
Download mbox | patch
Permalink /patch/14460/
State Accepted
Headers show

Comments

Yuya Nishihara - April 9, 2016, 10:56 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1459866618 -32400
#      Tue Apr 05 23:30:18 2016 +0900
# Node ID e32c0ef0b7631ac4f2b642411d5048e2c3108e69
# Parent  72ff97a833fedf7ab5603ae488578e333c449924
tests: import mercurial modules by name in test-propertycache

This is our convention, and silences import-checker.py that would say
imports weren't lexically sorted.

Patch

diff --git a/tests/test-propertycache.py b/tests/test-propertycache.py
--- a/tests/test-propertycache.py
+++ b/tests/test-propertycache.py
@@ -7,16 +7,18 @@  regression."""
 from __future__ import absolute_import, print_function
 import os
 import subprocess
-import mercurial.localrepo
-import mercurial.util
-import mercurial.hg
-import mercurial.ui as uimod
 
+from mercurial import (
+    hg,
+    localrepo,
+    ui as uimod,
+    util,
+)
 
 # create some special property cache that trace they call
 
 calllog = []
-@mercurial.util.propertycache
+@util.propertycache
 def testcachedfoobar(repo):
     name = repo.filtername
     if name is None:
@@ -26,7 +28,7 @@  def testcachedfoobar(repo):
     return val
 
 unficalllog = []
-@mercurial.localrepo.unfilteredpropertycache
+@localrepo.unfilteredpropertycache
 def testcachedunfifoobar(repo):
     name = repo.filtername
     if name is None:
@@ -36,8 +38,8 @@  def testcachedunfifoobar(repo):
     return val
 
 #plug them on repo
-mercurial.localrepo.localrepository.testcachedfoobar = testcachedfoobar
-mercurial.localrepo.localrepository.testcachedunfifoobar = testcachedunfifoobar
+localrepo.localrepository.testcachedfoobar = testcachedfoobar
+localrepo.localrepository.testcachedunfifoobar = testcachedunfifoobar
 
 
 # Create an empty repo and instantiate it. It is important to run
@@ -45,7 +47,7 @@  mercurial.localrepo.localrepository.test
 repopath = os.path.join(os.environ['TESTTMP'], 'repo')
 assert subprocess.call(['hg', 'init', repopath]) == 0
 ui = uimod.ui()
-repo = mercurial.hg.repository(ui, path=repopath).unfiltered()
+repo = hg.repository(ui, path=repopath).unfiltered()
 
 
 print('')