From 92bf2cff525daec69b6f4a48eec79ab0d97db10f Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 18 Jun 2015 18:43:29 +0100 Subject: [PATCH] miniter test, more specific exceptions, version 1.1 --- setup.py | 2 +- tqdm/_tqdm.py | 2 +- tqdm/tests/tests_tqdm.py | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 612f934a..c304dd5e 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='tqdm', - version='2.0', + version='1.1', description='A Simple Python Progress Meter', license='MIT License', author='Noam Yorav-Raphael', diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 50396328..6396a3e3 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -54,7 +54,7 @@ def format_meter(n, total, elapsed, ncols=None, prefix=''): try: unich = unichr - except: + except NameError: unich = chr bar = unich(0x2588)*bar_length diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py index d5e9a371..6793c374 100644 --- a/tqdm/tests/tests_tqdm.py +++ b/tqdm/tests/tests_tqdm.py @@ -22,7 +22,7 @@ def test_format_interval(): def test_format_meter(): try: unich = unichr - except: + except NameError: unich = chr assert format_meter(0, 1000, 13) == \ @@ -50,7 +50,7 @@ def test_iterate_over_csv_rows(): test_csv_file = StringIO() writer = csv.writer(test_csv_file) for i in range(3): - writer.writerow(['test', 'test', 'test']) + writer.writerow(['test']*3) test_csv_file.seek(0) # Test that nothing fails if we iterate over rows @@ -110,3 +110,11 @@ def test_min_interval(): pass our_file.seek(0) assert " 0%| | 0/3 [00:00<" in our_file.read() + + +def test_min_iters(): + our_file = StringIO() + for i in tqdm(range(3), file=our_file, leave=True, miniters=4): + our_file.write('blank\n') + our_file.seek(0) + assert '\nblank\nblank\n' in our_file.read()