From 929a4fdacfaebb844d447ba0b26afc433b400d14 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sat, 22 Oct 2016 14:17:52 +0100 Subject: [PATCH] safety and warning suppression --- examples/include_no_requirements.py | 2 +- tqdm/_tqdm_notebook.py | 2 +- tqdm/tests/tests_main.py | 11 ++--------- tqdm/tests/tests_tqdm.py | 4 ++-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/examples/include_no_requirements.py b/examples/include_no_requirements.py index 874be0c1..e7280d84 100644 --- a/examples/include_no_requirements.py +++ b/examples/include_no_requirements.py @@ -1,7 +1,7 @@ # How to import tqdm without enforcing it as a dependency try: from tqdm import tqdm -except: +except ImportError: def tqdm(*args, **kwargs): if args: return args[0] diff --git a/tqdm/_tqdm_notebook.py b/tqdm/_tqdm_notebook.py index 91cdbcbb..fe2aec3f 100644 --- a/tqdm/_tqdm_notebook.py +++ b/tqdm/_tqdm_notebook.py @@ -215,7 +215,7 @@ class tqdm_notebook(tqdm): else: self.sp(close=True) - def moveto(*args, **kwargs): + def moveto(self, *args, **kwargs): # void -> avoid extraneous `\n` in IPython output cell return diff --git a/tqdm/tests/tests_main.py b/tqdm/tests/tests_main.py index e3f660f8..9835130f 100644 --- a/tqdm/tests/tests_main.py +++ b/tqdm/tests/tests_main.py @@ -1,7 +1,6 @@ import sys import subprocess from tqdm import main, TqdmKeyError, TqdmTypeError -from copy import deepcopy from tests_tqdm import with_setup, pretest, posttest, _range, closing, UnicodeIO @@ -29,10 +28,7 @@ def test_main(): assert (ls_out in res.replace('\r\n', '\n')) # semi-fake test which gets coverage: - try: - _SYS = (deepcopy(sys.stdin), deepcopy(sys.argv)) - except: - pass + _SYS = sys.stdin, sys.argv with closing(UnicodeIO()) as sys.stdin: sys.argv = ['', '--desc', 'Test CLI delims', @@ -85,7 +81,4 @@ def test_main(): pass # clean up - try: - sys.stdin, sys.argv = _SYS - except: - pass + sys.stdin, sys.argv = _SYS diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py index 75ffdfe5..b25bb6bd 100644 --- a/tqdm/tests/tests_tqdm.py +++ b/tqdm/tests/tests_tqdm.py @@ -16,7 +16,7 @@ from tqdm import TqdmDeprecationWarning try: from StringIO import StringIO -except: +except ImportError: from io import StringIO from io import IOBase # to support unicode strings @@ -1119,7 +1119,7 @@ def test_clear(): @with_setup(pretest, posttest) -def test_clear(): +def test_clear_disabled(): """ Test clearing bar display """ with closing(StringIO()) as our_file: with tqdm(total=10, file=our_file, desc='pos0 bar', disable=True,