Skip to content
This repository was archived by the owner on Feb 19, 2023. It is now read-only.

Commit 10b166b

Browse files
committed
start writing test
1 parent 92aff77 commit 10b166b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import ast
2+
import tokenize
3+
from io import StringIO
4+
5+
import pytest
6+
7+
from pandas_dev_flaker.__main__ import run
8+
9+
10+
def results(s):
11+
return {
12+
"{}:{}: {}".format(*r)
13+
for r in run(
14+
ast.parse(s),
15+
list(tokenize.generate_tokens(StringIO(s).readline)),
16+
)
17+
}
18+
19+
20+
@pytest.mark.parametrize(
21+
"source",
22+
(
23+
pytest.param(
24+
"ab = 3",
25+
id="Multi-letter assignment",
26+
),
27+
),
28+
)
29+
def test_noop(source):
30+
assert not results(source)
31+
32+
33+
@pytest.mark.parametrize(
34+
"source, expected",
35+
(
36+
pytest.param(
37+
"a = 3",
38+
"1:0: PDF023 don't assign to single-letter variables",
39+
id="Single letter variable",
40+
),
41+
),
42+
)
43+
def test_violation(source, expected):
44+
(result,) = results(source)
45+
assert result == expected

0 commit comments

Comments
 (0)