[PATCH 4 of 6 V2] tests: use absolute_import in test-hgweb-auth.py

Yuya Nishihara yuya at tcha.org
Mon Apr 4 08:43:30 EDT 2016


On Mon, 04 Apr 2016 01:53:42 +0300, Robert Stanca wrote:
> --- a/tests/test-hgweb-auth.py	Mon Apr 04 00:29:03 2016 +0300
> +++ b/tests/test-hgweb-auth.py	Mon Apr 04 00:55:36 2016 +0300
> @@ -1,3 +1,5 @@
> +from __future__ import absolute_import
> +
>  try:
>      import urllib2
>      httppasswordmgrwithdefaultrealm = urllib2.HTTPPasswordMgrWithDefaultRealm
> @@ -7,9 +9,14 @@
>          urllib.request.HTTPPasswordMgrWithDefaultRealm
>  
>  from mercurial import demandimport; demandimport.enable()
> -from mercurial import ui, util
> -from mercurial import url
> -from mercurial.error import Abort
> +from mercurial import (
> +    ui,

ui as uimod

FWIW, I had a bad time to enable import-checker.py for tests/**.py, which
currently spills lots of warnings because many tests have already been ported
to absolute_import without coverage of import-checker.

The silenttestrunner is interesting. import-checker.py complains 'stdlib
import "unittest" follows local import: silenttestrunner', for example, but
if I reordered them, it said 'imports not lexically sorted:
silenttestrunner < unittest'. Dead-lock.

% ./contrib/import-checker.py mercurial/**/*.py hgext/**/*.py tests/**/*.py
tests/dumbhttp.py:10: imports not lexically sorted: BaseHTTPServer < optparse
tests/dumbhttp.py:12: imports not lexically sorted: SimpleHTTPServer < signal
tests/failfilemerge.py:5: imports from mercurial not lexically sorted: extensions < filemerge
tests/failfilemerge.py:5: imports from mercurial not lexically sorted: error < extensions
tests/hghave.py:270: relative import of stdlib module
tests/hypothesishelpers.py:20: imports not lexically sorted: hypothesis.strategies < traceback
tests/hypothesishelpers.py:21: relative import of stdlib module
tests/hypothesishelpers.py:21: direct symbol import given from hypothesis
tests/hypothesishelpers.py:14: relative import of stdlib module
tests/hypothesishelpers.py:15: relative import of stdlib module
tests/hypothesishelpers.py:19: relative import of stdlib module
tests/test-ancestor.py:12: ui from mercurial must be "as" aliased to uimod
tests/test-batching.py:9: direct symbol import localbatch, batchable, future from mercurial.peer
tests/test-batching.py:9: imports from mercurial.peer not lexically sorted: batchable < localbatch
tests/test-batching.py:14: direct symbol import remotebatch from mercurial.wireproto
tests/test-context.py:3: ui from mercurial must be "as" aliased to uimod
tests/test-ctxmanager.py:4: stdlib import "unittest" follows local import: silenttestrunner
tests/test-ctxmanager.py:6: direct symbol import ctxmanager from mercurial.util
tests/test-duplicateoptions.py:3: ui from mercurial must be "as" aliased to uimod
tests/test-filecache.py:10: imports from mercurial not lexically sorted: scmutil < util
tests/test-filecache.py:10: imports from mercurial not lexically sorted: extensions < scmutil
tests/test-filecache.py:10: ui from mercurial must be "as" aliased to uimod
tests/test-filelog.py:6: ui from mercurial must be "as" aliased to uimod
tests/test-hg-parseurl.py:2: direct symbol import parseurl from mercurial.hg
tests/test-hgweb-auth.py:12: ui from mercurial must be "as" aliased to uimod
tests/test-hgweb-auth.py:17: direct symbol import Abort from mercurial.error
tests/test-lock.py:6: stdlib import "tempfile" follows local import: silenttestrunner
tests/test-lock.py:7: stdlib import "types" follows local import: silenttestrunner
tests/test-lock.py:8: stdlib import "unittest" follows local import: silenttestrunner
tests/test-minirst.py:2: relative import of stdlib module
tests/test-minirst.py:2: direct symbol import pprint from pprint
tests/test-parseindex2.py:14: stdlib import "struct" follows local import: mercurial.node
tests/test-parseindex2.py:15: stdlib import "subprocess" follows local import: mercurial.node
tests/test-parseindex2.py:16: stdlib import "sys" follows local import: mercurial.node
tests/test-propertycache.py:10: imports not lexically sorted: mercurial.localrepo < subprocess
tests/test-propertycache.py:13: imports not lexically sorted: mercurial.hg < mercurial.util
tests/test-revlog-ancestry.py:3: ui from mercurial must be "as" aliased to uimod
tests/test-status-inprocess.py:3: direct symbol import ui from mercurial.ui
tests/test-status-inprocess.py:3: ui from mercurial.ui must be "as" aliased to uimod
tests/test-status-inprocess.py:6: direct symbol import localrepository from mercurial.localrepo
tests/test-status-inprocess.py:9: direct symbol import add, commit, status from mercurial.commands
tests/test-ui-config.py:2: ui from mercurial must be "as" aliased to uimod
tests/test-ui-verbosity.py:4: ui from mercurial must be "as" aliased to uimod
tests/test-verify-repo-operations.py:1: imports from __future__ not lexically sorted: absolute_import < print_function
tests/test-verify-repo-operations.py:37: imports not lexically sorted: binascii < sys
tests/test-verify-repo-operations.py:38: relative import of stdlib module
tests/test-verify-repo-operations.py:38: direct symbol import contextmanager from contextlib
tests/test-verify-repo-operations.py:43: stdlib import "subprocess" follows local import: silenttestrunner
tests/test-verify-repo-operations.py:45: relative import of stdlib module
tests/test-verify-repo-operations.py:45: direct symbol import HypothesisException from hypothesis.errors
tests/test-verify-repo-operations.py:46: relative import of stdlib module
tests/test-verify-repo-operations.py:46: direct symbol import rule, RuleBasedStateMachine, Bundle, precondition from hypothesis.stateful
tests/test-verify-repo-operations.py:46: imports from hypothesis.stateful not lexically sorted: RuleBasedStateMachine < rule
tests/test-verify-repo-operations.py:46: imports from hypothesis.stateful not lexically sorted: Bundle < RuleBasedStateMachine
tests/test-verify-repo-operations.py:48: relative import of stdlib module
tests/test-verify-repo-operations.py:48: direct symbol import settings, note, strategies from hypothesis
tests/test-verify-repo-operations.py:48: imports from hypothesis not lexically sorted: note < settings
tests/test-verify-repo-operations.py:49: relative import of stdlib module
tests/test-verify-repo-operations.py:49: direct symbol import set_hypothesis_home_dir from hypothesis.configuration
tests/test-verify-repo-operations.py:50: relative import of stdlib module
tests/test-verify-repo-operations.py:50: direct symbol import ExampleDatabase from hypothesis.database
tests/test-verify-repo-operations.py:22: relative import of stdlib module
tests/test-walkrepo.py:5: ui from mercurial must be "as" aliased to uimod
tests/tinyproxy.py:21: imports not lexically sorted: SocketServer < socket
tests/tinyproxy.py:143: relative import of stdlib module
Import cycle: hgext.largefiles.basestore -> hgext.largefiles.localstore -> hgext.largefiles.basestore


More information about the Mercurial-devel mailing list