forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sync_flake8_versions.py
125 lines (118 loc) · 3.48 KB
/
test_sync_flake8_versions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import pytest
from ..sync_flake8_versions import get_revisions
def test_wrong_env_flake8(capsys):
precommit_config = {
"repos": [
{
"repo": "https://gitlab.com/pycqa/flake8",
"rev": "0.1.1",
"hooks": [
{
"id": "flake8",
}
],
},
]
}
environment = {
"dependencies": [
"flake8=1.5.6",
]
}
with pytest.raises(SystemExit, match=None):
get_revisions(precommit_config, environment)
result, _ = capsys.readouterr()
expected = (
"flake8 in 'environment.yml' does not match in 'flake8' from 'pre-commit'\n"
)
assert result == expected
def test_wrong_env_add_dep(capsys):
precommit_config = {
"repos": [
{
"repo": "https://gitlab.com/pycqa/flake8",
"rev": "0.1.1",
"hooks": [
{
"id": "flake8",
"additional_dependencies": [
"flake8-bugs==1.1.1",
],
}
],
},
{
"repo": "https://github.com/asottile/yesqa",
"rev": "v1.2.2",
"hooks": [
{
"id": "yesqa",
"additional_dependencies": [
"flake8==0.4.2",
"flake8-bugs==1.1.1",
],
}
],
},
]
}
environment = {
"dependencies": [
"flake8=1.5.6",
"flake8-bugs=1.1.2",
]
}
with pytest.raises(SystemExit, match=None):
get_revisions(precommit_config, environment)
result, _ = capsys.readouterr()
expected = (
"Mismatch of 'flake8-bugs' version between 'enviroment.yml' "
"and additional dependencies of 'flake8' in '.pre-commit-config.yaml'\n"
)
assert result == expected
def test_get_revisions_no_failure(capsys):
precommit_config = {
"repos": [
{
"repo": "https://gitlab.com/pycqa/flake8",
"rev": "0.1.1",
"hooks": [
{
"id": "flake8",
"additional_dependencies": [
"pandas-dev-flaker==0.4.0",
"flake8-bugs==1.1.1",
],
}
],
},
{
"repo": "https://github.com/asottile/yesqa",
"rev": "v1.2.2",
"hooks": [
{
"id": "yesqa",
"additional_dependencies": [
"flake8==0.1.1",
"pandas-dev-flaker==0.4.0",
"flake8-bugs==1.1.1",
],
}
],
},
]
}
environment = {
"dependencies": [
"flake8=0.1.1",
"flake8-bugs=1.1.1",
{
"pip": [
"git+https://github.com/pydata/pydata-sphinx-theme.git@master",
"pandas-dev-flaker==0.4.0",
]
},
]
}
# should not raise
get_revisions(precommit_config, environment)