Patchwork D2580: tests: fix various test-check-module-imports.t violations

login
register
mail settings
Submitter phabricator
Date March 3, 2018, 2:37 p.m.
Message ID <differential-rev-PHID-DREV-mkcojhdubxteswt5km3l-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28778/
State Superseded
Headers show

Comments

phabricator - March 3, 2018, 2:37 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Somehow these are only caught when running the test under Python 3.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2580

AFFECTED FILES
  tests/test-i18n.t
  tests/test-lfs.t
  tests/test-resolve.t
  tests/test-rollback.t
  tests/test-split.t

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - March 3, 2018, 3:53 p.m.
pulkit added inline comments.

INLINE COMMENTS

> test-i18n.t:58
> +  > from mercurial.i18n import _
>    > from mercurial import encoding, registrar
>    > cmdtable = {}

I am not sure why we need this but according to rest of the patch, these couple of imports should be in new lines.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2580

To: durin42, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - March 3, 2018, 6:02 p.m.
durin42 added inline comments.

INLINE COMMENTS

> pulkit wrote in test-i18n.t:58
> I am not sure why we need this but according to rest of the patch, these couple of imports should be in new lines.

The linter doesn't enforce that, so I didn't bother. Two imports felt short enough as to not explode it out into multiple lines.

The import checker does require that importing encoding or registrar has to come after importing _ from i18n.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2580

To: durin42, #hg-reviewers
Cc: pulkit, mercurial-devel

Patch

diff --git a/tests/test-split.t b/tests/test-split.t
--- a/tests/test-split.t
+++ b/tests/test-split.t
@@ -2,7 +2,8 @@ 
 
   $ cat > $TESTTMP/editor.py <<EOF
   > #!$PYTHON
-  > import os, sys
+  > import os
+  > import sys
   > path = os.path.join(os.environ['TESTTMP'], 'messages')
   > messages = open(path).read().split('--\n')
   > prompt = open(sys.argv[1]).read()
diff --git a/tests/test-rollback.t b/tests/test-rollback.t
--- a/tests/test-rollback.t
+++ b/tests/test-rollback.t
@@ -220,8 +220,8 @@ 
   > import errno
   > from mercurial.i18n import _
   > from mercurial import (
+  >     error,
   >     registrar,
-  >     error,
   >     ui as uimod,
   > )
   > 
diff --git a/tests/test-resolve.t b/tests/test-resolve.t
--- a/tests/test-resolve.t
+++ b/tests/test-resolve.t
@@ -85,7 +85,12 @@ 
 
   $ cat > $TESTTMP/markdriver.py << EOF
   > '''mark and unmark files as driver-resolved'''
-  > from mercurial import merge, registrar, scmutil, pycompat
+  > from mercurial import (
+  >    merge,
+  >    pycompat,
+  >    registrar,
+  >    scmutil,
+  > )
   > cmdtable = {}
   > command = registrar.command(cmdtable)
   > @command(b'markdriver',
diff --git a/tests/test-lfs.t b/tests/test-lfs.t
--- a/tests/test-lfs.t
+++ b/tests/test-lfs.t
@@ -616,8 +616,8 @@ 
   $ cat > $TESTTMP/dumpflog.py << EOF
   > # print raw revision sizes, flags, and hashes for certain files
   > import hashlib
+  > from mercurial.node import short
   > from mercurial import revlog
-  > from mercurial.node import short
   > def hash(rawtext):
   >     h = hashlib.sha512()
   >     h.update(rawtext)
diff --git a/tests/test-i18n.t b/tests/test-i18n.t
--- a/tests/test-i18n.t
+++ b/tests/test-i18n.t
@@ -54,8 +54,8 @@ 
 Check i18n cache isn't reused after encoding change:
 
   $ cat > $TESTTMP/encodingchange.py << EOF
+  > from mercurial.i18n import _
   > from mercurial import encoding, registrar
-  > from mercurial.i18n import _
   > cmdtable = {}
   > command = registrar.command(cmdtable)
   > @command(b'encodingchange', norepo=True)