Merge remote-tracking branch 'upstream/master' into ignore-uris

This commit is contained in:
jonmeow
2020-11-06 11:55:12 -08:00
15 changed files with 525 additions and 70 deletions

View File

@ -729,6 +729,39 @@ def test_uri_regex_def():
assert not uri_regex.findall(boilerplate % uri), uri
def test_config(tmpdir, capsys):
"""
Tests loading options from a config file.
"""
d = str(tmpdir)
# Create sample files.
with open(op.join(d, 'bad.txt'), 'w') as f:
f.write('abandonned donn\n')
with open(op.join(d, 'good.txt'), 'w') as f:
f.write("good")
# Create a config file.
conffile = op.join(d, 'config.cfg')
with open(conffile, 'w') as f:
f.write(
'[codespell]\n'
'skip = bad.txt\n'
'count = \n'
)
# Should fail when checking both.
code, stdout, _ = cs.main(d, count=True, std=True)
# Code in this case is not exit code, but count of misspellings.
assert code == 2
assert 'bad.txt' in stdout
# Should pass when skipping bad.txt
code, stdout, _ = cs.main('--config', conffile, d, count=True, std=True)
assert code == 0
assert 'bad.txt' not in stdout
@contextlib.contextmanager
def FakeStdin(text):
if sys.version[0] == '2':