forked from huacnlee/autocorrect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_autocorrect_py.py
49 lines (40 loc) · 1.43 KB
/
test_autocorrect_py.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
import autocorrect_py as autocorrect
import pytest
@pytest.mark.parametrize(
"text,expected",
[
("Hello你好.", "Hello 你好。"),
],
)
def test_format(text, expected):
output = autocorrect.format(text)
assert output == expected
@pytest.mark.parametrize(
"raw,filename,expected",
[
("<h1>Hello你好.</h1>", "html", "<h1>Hello 你好。</h1>"),
],
)
def test_format_for(raw, filename, expected):
output = autocorrect.format_for(raw, filename)
assert output == expected
def test_lint_for():
output = autocorrect.lint_for("<h1>这是 Heading 标题</h1>", "index.html")
assert not output.lines
output = autocorrect.lint_for("<h1>这是 Heading标题</h1>", "html")
assert len(output.lines) == 1
line = output.lines[0]
assert line.line == 1
assert line.col == 5
assert line.new == "这是 Heading 标题"
def test_load_config():
autocorrect.load_config('{ textRules: { "你好hello": 0 } }')
assert autocorrect.format("Hello你好.") == "Hello 你好。"
assert autocorrect.format("你好hello.") == "你好hello."
def test_ignorer():
ignorer = autocorrect.Ignorer("../")
assert ignorer.is_ignored("README.md") == True
assert ignorer.is_ignored("src/lib.rs") == True
assert ignorer.is_ignored("target/foo/bar") == True
assert ignorer.is_ignored("Cagro.toml") == False
assert ignorer.is_ignored("autocorrect-rb.gemspec") == False