mirror of
https://github.com/codespell-project/codespell.git
synced 2025-08-06 09:40:56 +08:00
Check errors don't exist as valid words in the aspell dictionary (#1142)
* Check errors don't exist as valid words in the aspell dictionary * Install aspell on Travis * Add some missing packages * Remove a virtual package * Just install the version of aspell-python we need * Keep flake8 happy * Switch to warnings and count them, so we can see all the aspell errors in one go * Handle different encoding of the word and aspell * Try and fix the encoding conversion * Find out the encoding type * Don't assert on number of warnings * Don't record warnings for now * Warn on all the encoding options * pprint the encoding * More warning work * Use the actual encoding type * Correct the logic * ENH: Multi dict support * FIX: Fixes after merge * FIX: Better error check * FIX: More thorough testing, locations * FIX: Try newer aspell * FIX: Move to new dict * FIX: Move * FIX: Restore removals from #1181 * FIX: One from #1362 * Add rare chack->check, cheque, * Minor tidy of some dictionary check code * Add some more suggestions. * Fix the whitespace * Really fix the whitespace * FIX: Refactor requirement * Log an error when aspell not found and not required * Fix the error logging * Test all variants of present and missing from aspell * Undo some tuple tidying * Fix the true/false values used * Skip some flake8 tests * Fix the test cases * Correct the not in aspell test and fix some test cases * Remove a duplicate test * Use a test word that isn't a typo * Set the ideal aspell detection logic for each dictionary I suspect we'll have to relax this as more obscure words won't be in the aspell dictionary * Be more realistic given the size of the dictionary * Fix a flake8 error * Fix another line length error * FIX: Move * FIX: Make visible, simplify Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
This commit is contained in:
@ -31,24 +31,35 @@ def test_command(tmpdir):
|
||||
def test_basic(tmpdir, capsys):
|
||||
"""Test some basic functionality"""
|
||||
assert cs.main('_does_not_exist_') == 0
|
||||
with open(op.join(str(tmpdir), 'tmp'), 'w') as f:
|
||||
fname = op.join(str(tmpdir), 'tmp')
|
||||
with open(fname, 'w') as f:
|
||||
pass
|
||||
assert cs.main('-D', 'foo', f.name) == 1, 'missing dictionary'
|
||||
try:
|
||||
assert 'cannot find dictionary' in capsys.readouterr()[1]
|
||||
assert cs.main(f.name) == 0, 'empty file'
|
||||
with open(f.name, 'a') as f:
|
||||
f.write('this is a test file\n')
|
||||
assert cs.main(f.name) == 0, 'good'
|
||||
with open(f.name, 'a') as f:
|
||||
f.write('abandonned\n')
|
||||
assert cs.main(f.name) == 1, 'bad'
|
||||
with open(f.name, 'a') as f:
|
||||
f.write('abandonned\n')
|
||||
assert cs.main(f.name) == 2, 'worse'
|
||||
finally:
|
||||
os.remove(f.name)
|
||||
assert 'cannot find dictionary' in capsys.readouterr()[1]
|
||||
assert cs.main(fname) == 0, 'empty file'
|
||||
with open(fname, 'a') as f:
|
||||
f.write('this is a test file\n')
|
||||
assert cs.main(fname) == 0, 'good'
|
||||
with open(fname, 'a') as f:
|
||||
f.write('abandonned\n')
|
||||
assert cs.main(fname) == 1, 'bad'
|
||||
with open(fname, 'a') as f:
|
||||
f.write('abandonned\n')
|
||||
assert cs.main(fname) == 2, 'worse'
|
||||
with open(fname, 'a') as f:
|
||||
f.write('tim\ngonna\n')
|
||||
assert cs.main(fname) == 2, 'with a name'
|
||||
assert cs.main('--builtin', 'clear,rare,names,informal', fname) == 4
|
||||
capsys.readouterr()
|
||||
assert cs.main(fname, '--builtin', 'foo') == 1 # bad type sys.exit(1)
|
||||
stdout = capsys.readouterr()[1]
|
||||
assert 'Unknown builtin dictionary' in stdout
|
||||
d = str(tmpdir)
|
||||
assert cs.main(fname, '-D', op.join(d, 'foo')) == 1 # bad dict
|
||||
stdout = capsys.readouterr()[1]
|
||||
assert 'cannot find dictionary' in stdout
|
||||
os.remove(fname)
|
||||
|
||||
with open(op.join(d, 'bad.txt'), 'w') as f:
|
||||
f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd')
|
||||
assert cs.main(d) == 4
|
||||
|
Reference in New Issue
Block a user