"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "codespell_lib/tests/test_basic.py" between
codespell-1.16.0.tar.gz and codespell-1.17.1.tar.gz

About: codespell-.* codespell checks source code and other text files for common misspellings.

test_basic.py  (codespell-1.16.0):test_basic.py  (codespell-1.17.1)
skipping to change at line 31 skipping to change at line 31
# With no arguments does "." # With no arguments does "."
d = str(tmpdir) d = str(tmpdir)
assert run_codespell(cwd=d) == 0 assert run_codespell(cwd=d) == 0
with open(op.join(d, 'bad.txt'), 'w') as f: with open(op.join(d, 'bad.txt'), 'w') as f:
f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd') f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd')
assert run_codespell(cwd=d) == 4 assert run_codespell(cwd=d) == 4
def test_basic(tmpdir, capsys): def test_basic(tmpdir, capsys):
"""Test some basic functionality""" """Test some basic functionality"""
assert cs.main('_does_not_exist_') == 0 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 pass
assert cs.main('-D', 'foo', f.name) == 1, 'missing dictionary' assert cs.main('-D', 'foo', f.name) == 1, 'missing dictionary'
try: assert 'cannot find dictionary' in capsys.readouterr()[1]
assert 'cannot find dictionary' in capsys.readouterr()[1] assert cs.main(fname) == 0, 'empty file'
assert cs.main(f.name) == 0, 'empty file' with open(fname, 'a') as f:
with open(f.name, 'a') as f: f.write('this is a test file\n')
f.write('this is a test file\n') assert cs.main(fname) == 0, 'good'
assert cs.main(f.name) == 0, 'good' with open(fname, 'a') as f:
with open(f.name, 'a') as f: f.write('abandonned\n')
f.write('abandonned\n') assert cs.main(fname) == 1, 'bad'
assert cs.main(f.name) == 1, 'bad' with open(fname, 'a') as f:
with open(f.name, 'a') as f: f.write('abandonned\n')
f.write('abandonned\n') assert cs.main(fname) == 2, 'worse'
assert cs.main(f.name) == 2, 'worse' with open(fname, 'a') as f:
finally: f.write('tim\ngonna\n')
os.remove(f.name) 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) 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: with open(op.join(d, 'bad.txt'), 'w') as f:
f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd') f.write('abandonned\nAbandonned\nABANDONNED\nAbAnDoNnEd')
assert cs.main(d) == 4 assert cs.main(d) == 4
capsys.readouterr() capsys.readouterr()
assert cs.main('-w', d) == 0 assert cs.main('-w', d) == 0
assert 'FIXED:' in capsys.readouterr()[1] assert 'FIXED:' in capsys.readouterr()[1]
with open(op.join(d, 'bad.txt')) as f: with open(op.join(d, 'bad.txt')) as f:
new_content = f.read() new_content = f.read()
assert cs.main(d) == 0 assert cs.main(d) == 0
assert new_content == 'abandoned\nAbandoned\nABANDONED\nabandoned' assert new_content == 'abandoned\nAbandoned\nABANDONED\nabandoned'
 End of changes. 3 change blocks. 
15 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)