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

login
register
mail settings
Submitter roby roby
Date April 3, 2016, 10:53 p.m.
Message ID <53eec7dd8268f7d5ea83.1459724022@roby>
Download mbox | patch
Permalink /patch/14303/
State Accepted
Headers show

Comments

roby roby - April 3, 2016, 10:53 p.m.
# HG changeset patch
# User Robert Stanca <robert.stanca7@gmail.com>
# Date 1459720536 -10800
#      Mon Apr 04 00:55:36 2016 +0300
# Node ID 53eec7dd8268f7d5ea8363dff3e3d0947f1b43cb
# Parent  e91e1960e4b0e9c73142fa54805a3fae61c43182
tests: use absolute_import in test-hgweb-auth.py
Yuya Nishihara - April 4, 2016, 12:43 p.m.
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

Patch

diff -r e91e1960e4b0 -r 53eec7dd8268 tests/test-check-py3-compat.t
--- a/tests/test-check-py3-compat.t	Mon Apr 04 00:29:03 2016 +0300
+++ b/tests/test-check-py3-compat.t	Mon Apr 04 00:55:36 2016 +0300
@@ -56,7 +56,6 @@ 
   tests/test-demandimport.py not using absolute_import
   tests/test-demandimport.py requires print_function
   tests/test-doctest.py not using absolute_import
-  tests/test-hgweb-auth.py not using absolute_import
   tests/test-hgweb-auth.py requires print_function
   tests/test-hgwebdir-paths.py not using absolute_import
   tests/test-hybridencode.py not using absolute_import
diff -r e91e1960e4b0 -r 53eec7dd8268 tests/test-hgweb-auth.py
--- 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,
+    url,
+    util,
+)
+from mercurial.error import (
+    Abort,
+)
 
 class myui(ui.ui):
     def interactive(self):