Skip to content
GitLab
探索
项目
群组
代码片段
项目
群组
代码片段
/
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录
切换导航
菜单
打开侧边栏
ExternalRepo
pre-commit-hooks
提交
4af74511
提交
4af74511
编辑于
8年前
作者:
Daniel Gallagher
浏览文件
操作
下载
电子邮件补丁
差异文件
Update README.md about file-contents-sorter
上级
8b41c575
main
remove-fix-encoding-pragma
v4.6.0
v4.5.0
v4.4.0
v4.3.0
v4.2.0
v4.1.0
v4.0.1
v4.0.0
v3.4.0
v3.3.0
v3.2.0
v3.1.0
v3.0.1
v3.0.0
v2.5.0
v2.4.0
v2.3.0
v2.2.3
v2.2.2
v2.2.1
v2.2.0
v2.1.0
v2.0.0
v1.4.0
v1.4.0-1
v1.3.0
v1.2.3
v1.2.2
v1.2.1
v1.2.1-1
v1.2.0
v1.1.1
v1.1.0
v1.0.0
v0.9.5
v0.9.4
v0.9.3
v0.9.2
v0.9.1
v0.9.0
无相关合并请求
变更
2
Hide whitespace changes
Inline
Side-by-side
显示
2 个更改的文件
README.md
+1
-0
README.md
tests/file_contents_sorter_test.py
+12
-14
tests/file_contents_sorter_test.py
有
13 个添加
和
14 个删除
+13
-14
README.md
+
1
-
0
浏览文件 @
4af74511
...
...
@@ -51,6 +51,7 @@ Add this to your `.pre-commit-config.yaml`
with single quoted strings.
-
`end-of-file-fixer`
- Makes sure files end in a newline and only a newline.
-
`fix-encoding-pragma`
- Add
`# -*- coding: utf-8 -*-`
to the top of python files.
-
`file-contents-sorter`
- Sort the lines in specified files (defaults to alphabetical). You must provide list of target files as input to it.
-
To remove the coding pragma pass
`--remove`
(useful in a python3-only codebase)
-
`flake8`
- Run flake8 on your python files.
-
`forbid-new-submodules`
- Prevent addition of new git submodules.
...
...
This diff is collapsed.
Click to expand it.
tests/file_contents_sorter_test.py
+
12
-
14
浏览文件 @
4af74511
from
argparse
import
ArgumentError
import
pytest
from
pre_commit_hooks.file_contents_sorter
import
FAIL
from
pre_commit_hooks.file_contents_sorter
import
main
from
pre_commit_hooks.file_contents_sorter
import
parse_commandline_input
from
pre_commit_hooks.file_contents_sorter
import
PASS
from
pre_commit_hooks.file_contents_sorter
import
sort_file_contents
def
_n
(
*
strs
):
return
b
'
\n
'
.
join
(
strs
)
+
'
\n
'
return
b
'
\n
'
.
join
(
strs
)
+
b
'
\n
'
# Input, expected return value, expected output
TESTS
=
(
(
b
''
,
PASS
,
b
''
),
(
_n
(
'lonesome'
),
PASS
,
_n
(
'lonesome'
)),
(
_n
(
b
'lonesome'
),
PASS
,
_n
(
b
'lonesome'
)),
(
b
'missing_newline'
,
PASS
,
b
'missing_newline'
),
(
_n
(
'alpha'
,
'beta'
),
PASS
,
_n
(
'alpha'
,
'beta'
)),
(
_n
(
'beta'
,
'alpha'
),
FAIL
,
_n
(
'alpha'
,
'beta'
)),
(
_n
(
'C'
,
'c'
),
PASS
,
_n
(
'C'
,
'c'
)),
(
_n
(
'c'
,
'C'
),
FAIL
,
_n
(
'C'
,
'c'
)),
(
_n
(
'mag ical '
,
' tre vor'
),
FAIL
,
_n
(
' tre vor'
,
'mag ical '
)),
(
_n
(
'@'
,
'-'
,
'_'
,
'#'
),
FAIL
,
_n
(
'#'
,
'-'
,
'@'
,
'_'
)),
(
_n
(
b
'alpha'
,
b
'beta'
),
PASS
,
_n
(
b
'alpha'
,
b
'beta'
)),
(
_n
(
b
'beta'
,
b
'alpha'
),
FAIL
,
_n
(
b
'alpha'
,
b
'beta'
)),
(
_n
(
b
'C'
,
b
'c'
),
PASS
,
_n
(
b
'C'
,
b
'c'
)),
(
_n
(
b
'c'
,
b
'C'
),
FAIL
,
_n
(
b
'C'
,
b
'c'
)),
(
_n
(
b
'mag ical '
,
b
' tre vor'
),
FAIL
,
_n
(
b
' tre vor'
,
b
'mag ical '
)),
(
_n
(
b
'@'
,
b
'-'
,
b
'_'
,
b
'#'
),
FAIL
,
_n
(
b
'#'
,
b
'-'
,
b
'@'
,
b
'_'
)),
)
...
...
@@ -42,13 +39,14 @@ def test_parse_commandline_input_errors_without_args():
with
pytest
.
raises
(
SystemExit
):
parse_commandline_input
([])
@
pytest
.
mark
.
parametrize
(
(
'filename_list'
),
(
'filename_list'
),
(
[
'filename1'
],
[
'filename1'
],
[
'filename1'
,
'filename2'
],
)
)
def
test_parse_commandline_input_success
(
filename_list
):
args
=
parse_commandline_input
(
filename_list
)
assert
args
.
filenames
==
filename_list
\ No newline at end of file
assert
args
.
filenames
==
filename_list
This diff is collapsed.
Click to expand it.
编辑
预览
支持
Markdown
0%
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
菜单
探索
项目
群组
代码片段