Skip to content

Commit

Permalink
Fix closing of tqdm instances in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lrq3000 authored and casperdcl committed Jan 12, 2017
1 parent 9683c17 commit 8d5b776
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tqdm/tests/tests_tqdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1519,18 +1519,18 @@ def test_postfix():

# Test postfix set at init
with closing(StringIO()) as our_file:
t1 = tqdm(total=10, file=our_file, desc='pos0 bar',
bar_format='{r_bar}', postfix=postfix)
t1.refresh()
out = our_file.getvalue()
with tqdm(total=10, file=our_file, desc='pos0 bar',
bar_format='{r_bar}', postfix=postfix) as t1:
t1.refresh()
out = our_file.getvalue()

# Test postfix set after init
with closing(StringIO()) as our_file:
t2 = trange(10, file=our_file, desc='pos1 bar',
bar_format='{r_bar}', postfix=None)
t2.set_postfix(**postfix)
t2.refresh()
out2 = our_file.getvalue()
with trange(10, file=our_file, desc='pos1 bar',
bar_format='{r_bar}', postfix=None) as t2:
t2.set_postfix(**postfix)
t2.refresh()
out2 = our_file.getvalue()

# Order of items in dict may change, so need a loop to check per item
for res in expected:
Expand Down

0 comments on commit 8d5b776

Please sign in to comment.