mirror of
https://github.com/codespell-project/codespell.git
synced 2025-05-21 01:17:01 +08:00
Merge remote-tracking branch 'upstream/master' into ignore-uris
This commit is contained in:
@ -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':
|
||||
|
Reference in New Issue
Block a user