safety and warning suppression

This commit is contained in:
Casper da Costa-Luis 2016-10-22 14:17:52 +01:00
parent bde013b1da
commit 929a4fdacf
4 changed files with 6 additions and 13 deletions

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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,