mirror of https://github.com/tqdm/tqdm.git
tests
- test auto complete script - remove redundant test
This commit is contained in:
parent
40bda883a7
commit
795cd53d7f
|
@ -1,34 +0,0 @@
|
|||
import re
|
||||
import tqdm
|
||||
import tqdm.cli
|
||||
|
||||
RE_OPT = re.compile(r'(\w+) :', flags=re.M)
|
||||
|
||||
|
||||
def doc2opt(doc):
|
||||
return ('--' + i for i in RE_OPT.findall(doc))
|
||||
|
||||
|
||||
def test_autogenerate_cli():
|
||||
# CLI options
|
||||
options = {'-h', '--help', '-v', '--version'}
|
||||
for doc in (tqdm.tqdm.__init__.__doc__, tqdm.cli.CLI_EXTRA_DOC):
|
||||
options.update(doc2opt(doc))
|
||||
options.difference_update(
|
||||
'--' + i for i in ('name',) + tqdm.cli.UNSUPPORTED_OPTS)
|
||||
|
||||
# All options
|
||||
# Add new CLI options to this list
|
||||
all_opts = {
|
||||
'-h', '-v', '--help', '--version',
|
||||
'--desc', '--total', '--leave', '--ncols',
|
||||
'--mininterval', '--maxinterval', '--miniters',
|
||||
'--ascii', '--disable', '--unit', '--unit_scale',
|
||||
'--dynamic_ncols', '--smoothing', '--bar_format',
|
||||
'--initial', '--position', '--postfix', '--unit_divisor',
|
||||
'--bytes', '--write_bytes', '--lock_args', '--nrows',
|
||||
'--delim', '--buf_size', '--manpath', '--log',
|
||||
'--comppath'
|
||||
}
|
||||
|
||||
assert options == all_opts
|
|
@ -5,6 +5,7 @@ from shutil import rmtree
|
|||
from tempfile import mkdtemp
|
||||
from tqdm.cli import main, TqdmKeyError, TqdmTypeError
|
||||
from tqdm.utils import IS_WIN
|
||||
from io import open as io_open
|
||||
|
||||
from tests_tqdm import with_setup, pretest, posttest, _range, closing, \
|
||||
UnicodeIO, StringIO, SkipTest
|
||||
|
@ -115,6 +116,31 @@ def test_comppath():
|
|||
rmtree(tmp, True)
|
||||
|
||||
|
||||
def test_autocomplete():
|
||||
"""Test CLI auto completion arguments"""
|
||||
if IS_WIN:
|
||||
raise SkipTest
|
||||
tmp = mkdtemp()
|
||||
man = path.join(tmp, "tqdm_completion.sh")
|
||||
print(man)
|
||||
assert not path.exists(man)
|
||||
try:
|
||||
main(argv=['--comppath', tmp], fp=NULL)
|
||||
except SystemExit:
|
||||
pass
|
||||
else:
|
||||
raise SystemExit("Expected system exit")
|
||||
assert path.exists(man)
|
||||
with io_open(man, mode='r', encoding='utf-8') as fd:
|
||||
script = fd.read()
|
||||
opts = {
|
||||
'--help', '--desc', '--total', '--leave', '--ncols', '--ascii', '--dynamic_ncols',
|
||||
'--position', '--bytes', '--nrows', '--delim', '--manpath', '--comppath'
|
||||
}
|
||||
assert all(args in script for args in opts)
|
||||
rmtree(tmp, True)
|
||||
|
||||
|
||||
def test_exceptions():
|
||||
"""Test CLI Exceptions"""
|
||||
_SYS = sys.stdin, sys.argv
|
||||
|
|
Loading…
Reference in New Issue