Mercurial > hg
comparison tests/test-check-module-imports.t @ 29208:cba8bc11ed10
import-checker: extend check of symbol-import order to all local modules
It doesn't make sense that (a) is allowed whereas (b) is disallowed.
a) from mercurial import hg
from mercurial.i18n import _
b) from . import hg
from .i18n import _
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 May 2016 13:39:33 +0900 |
parents | 0ec8501af800 |
children | 8005e0e0eb33 |
comparison
equal
deleted
inserted
replaced
29207:a09098c61fea | 29208:cba8bc11ed10 |
---|---|
112 $ cat > testpackage/importfromrelative.py << EOF | 112 $ cat > testpackage/importfromrelative.py << EOF |
113 > from __future__ import absolute_import | 113 > from __future__ import absolute_import |
114 > from testpackage.unsorted import foo | 114 > from testpackage.unsorted import foo |
115 > EOF | 115 > EOF |
116 | 116 |
117 $ python "$import_checker" testpackage/*.py testpackage/subpackage/*.py | 117 $ mkdir testpackage2 |
118 $ touch testpackage2/__init__.py | |
119 | |
120 $ cat > testpackage2/latesymbolimport.py << EOF | |
121 > from __future__ import absolute_import | |
122 > from testpackage import unsorted | |
123 > from mercurial.node import hex | |
124 > EOF | |
125 | |
126 $ python "$import_checker" testpackage*/*.py testpackage/subpackage/*.py | |
118 testpackage/importalias.py:2: ui module must be "as" aliased to uimod | 127 testpackage/importalias.py:2: ui module must be "as" aliased to uimod |
119 testpackage/importfromalias.py:2: ui from testpackage must be "as" aliased to uimod | 128 testpackage/importfromalias.py:2: ui from testpackage must be "as" aliased to uimod |
120 testpackage/importfromrelative.py:2: import should be relative: testpackage.unsorted | 129 testpackage/importfromrelative.py:2: import should be relative: testpackage.unsorted |
121 testpackage/importfromrelative.py:2: direct symbol import foo from testpackage.unsorted | 130 testpackage/importfromrelative.py:2: direct symbol import foo from testpackage.unsorted |
122 testpackage/importsymbolfromsub.py:2: direct symbol import nonmodule from testpackage.subpackage | 131 testpackage/importsymbolfromsub.py:2: direct symbol import nonmodule from testpackage.subpackage |
130 testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage | 139 testpackage/subpackage/levelpriority.py:3: higher-level import should come first: testpackage |
131 testpackage/subpackage/localimport.py:7: multiple "from .. import" statements | 140 testpackage/subpackage/localimport.py:7: multiple "from .. import" statements |
132 testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority | 141 testpackage/subpackage/localimport.py:8: import should be relative: testpackage.subpackage.levelpriority |
133 testpackage/symbolimport.py:2: direct symbol import foo from testpackage.unsorted | 142 testpackage/symbolimport.py:2: direct symbol import foo from testpackage.unsorted |
134 testpackage/unsorted.py:3: imports not lexically sorted: os < sys | 143 testpackage/unsorted.py:3: imports not lexically sorted: os < sys |
144 testpackage2/latesymbolimport.py:3: symbol import follows non-symbol import: mercurial.node | |
135 [1] | 145 [1] |
136 | 146 |
137 $ cd "$TESTDIR"/.. | 147 $ cd "$TESTDIR"/.. |
138 | 148 |
139 There are a handful of cases here that require renaming a module so it | 149 There are a handful of cases here that require renaming a module so it |