mirror of
https://github.com/codespell-project/codespell.git
synced 2025-05-17 15:36:17 +08:00
Test to check our string escape word triggers on its own (#2879)
This commit is contained in:
3
.github/workflows/codespell-private.yml
vendored
3
.github/workflows/codespell-private.yml
vendored
@ -12,6 +12,7 @@ jobs:
|
||||
test:
|
||||
env:
|
||||
REQUIRE_ASPELL: true
|
||||
RUFF_FORMAT: github
|
||||
# Make sure we're using the latest aspell dictionary
|
||||
runs-on: ubuntu-22.04
|
||||
strategy:
|
||||
@ -75,6 +76,8 @@ jobs:
|
||||
- run: make check-dictionaries
|
||||
|
||||
ruff-annotation:
|
||||
env:
|
||||
RUFF_FORMAT: github
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup python
|
||||
|
@ -2,7 +2,7 @@ codespell
|
||||
=========
|
||||
|
||||
Fix common misspellings in text files. It's designed primarily for checking
|
||||
misspelled words in source code, but it can be used with other files as well.
|
||||
misspelled words in source code (backslash escapes are skipped), but it can be used with other files as well.
|
||||
It does not check for word membership in a complete dictionary, but instead
|
||||
looks for a set of common misspellings. Therefore it should catch errors like
|
||||
"adn", but it will not catch "adnasdfasdf". This also means it shouldn't
|
||||
|
@ -97,9 +97,6 @@ def test_basic(
|
||||
with fname.open("a") as f:
|
||||
f.write("this is a test file\n")
|
||||
assert cs.main(fname) == 0, "good"
|
||||
with fname.open("a") as f:
|
||||
f.write("var = '\\nDoes not error on newline'\n")
|
||||
assert cs.main(fname) == 0, "with string escape"
|
||||
with fname.open("a") as f:
|
||||
f.write("abandonned\n")
|
||||
assert cs.main(fname) == 1, "bad"
|
||||
@ -110,6 +107,14 @@ def test_basic(
|
||||
f.write("tim\ngonna\n")
|
||||
assert cs.main(fname) == 2, "with a name"
|
||||
assert cs.main("--builtin", "clear,rare,names,informal", fname) == 4
|
||||
with fname.open("w") as f: # overwrite the file
|
||||
f.write("var = 'nwe must check codespell likes escapes nin strings'\n")
|
||||
assert cs.main(fname) == 1, "checking our string escape test word is bad"
|
||||
# the first one is missed because the apostrophe means its not currently
|
||||
# treated as a word on its own
|
||||
with fname.open("w") as f: # overwrite the file
|
||||
f.write("var = '\\nwe must check codespell likes escapes \\nin strings'\n")
|
||||
assert cs.main(fname) == 0, "with string escape"
|
||||
result = cs.main(fname, "--builtin", "foo", std=True)
|
||||
assert isinstance(result, tuple)
|
||||
code, _, stderr = result
|
||||
|
Reference in New Issue
Block a user