Skip to content

Commit

Permalink
test CLI --null
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Sep 12, 2020
1 parent b0a55f4 commit 4b46c87
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tqdm/tests/tests_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,31 @@ def test_main():
# spaces to clear intermediate lines could increase length
assert len(fp.getvalue()) >= res + len(IN_DATA)

# test --null
_STDOUT = sys.stdout
try:
with closing(StringIO()) as sys.stdout:
with closing(StringIO()) as sys.stdin:
sys.stdin.write(IN_DATA)

sys.stdin.seek(0)
with closing(UnicodeIO()) as fp:
main(argv=['--null'], fp=fp)
assert not sys.stdout.getvalue()

with closing(StringIO()) as sys.stdin:
sys.stdin.write(IN_DATA)

sys.stdin.seek(0)
with closing(UnicodeIO()) as fp:
main(argv=[], fp=fp)
assert sys.stdout.getvalue()
except:
sys.stdout = _STDOUT
raise
else:
sys.stdout = _STDOUT

# test integer --update
with closing(StringIO()) as sys.stdin:
sys.stdin.write(IN_DATA)
Expand Down

0 comments on commit 4b46c87

Please sign in to comment.