From a432c3dacdaf166109bf6ba4d539b760c80534ed Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Sun, 15 Apr 2018 01:16:33 +0100 Subject: [PATCH] remove warning, flake8 --- tqdm/_main.py | 3 ++- tqdm/_tqdm.py | 5 ++++- tqdm/tests/tests_pandas.py | 14 +++----------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tqdm/_main.py b/tqdm/_main.py index 923324bd..86b933c6 100644 --- a/tqdm/_main.py +++ b/tqdm/_main.py @@ -128,7 +128,8 @@ def main(fp=sys.stderr): # sys.argv.pop(log) # logLevel = sys.argv.pop(log) logLevel = sys.argv[log + 1] - logging.basicConfig(level=getattr(logging, logLevel), + logging.basicConfig( + level=getattr(logging, logLevel), format="%(levelname)s:%(module)s:%(lineno)d:%(message)s") log = logging.getLogger(__name__) diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 95e07b7d..98389a07 100755 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -47,14 +47,17 @@ class TqdmWarning(Warning): """ def __init__(self, msg, fp_write=None, *a, **k): if fp_write is not None: - fp_write("\n" + self.__class__.__name__ + ": " + str(msg).rstrip() + '\n') + fp_write("\n" + self.__class__.__name__ + ": " + + str(msg).rstrip() + '\n') else: super(TqdmWarning, self).__init__(msg, *a, **k) + class TqdmExperimentalWarning(TqdmWarning, FutureWarning): """beta feature, unstable API and behaviour""" pass + class TqdmDeprecationWarning(TqdmWarning, DeprecationWarning): # not suppressed if raised pass diff --git a/tqdm/tests/tests_pandas.py b/tqdm/tests/tests_pandas.py index 37b69baf..45124c84 100644 --- a/tqdm/tests/tests_pandas.py +++ b/tqdm/tests/tests_pandas.py @@ -1,8 +1,7 @@ -from nose.plugins.skip import SkipTest -import warnings - from tqdm import tqdm -from tests_tqdm import with_setup, pretest, posttest, StringIO, closing +from tests_tqdm import with_setup, pretest, posttest, SkipTest, \ + StringIO, closing + @with_setup(pretest, posttest) def test_pandas_setup(): @@ -13,13 +12,6 @@ def test_pandas_setup(): except ImportError: raise SkipTest - with warnings.catch_warnings(record=True) as res: - warnings.simplefilter("always") - # set total in tqdm.pandas shall cause a warning - tqdm.pandas(total=100) - assert len(res) == 1 - assert all([i in str(res[-1].message) for i in ['total','not recommended']]) - with closing(StringIO()) as our_file: tqdm.pandas(file=our_file, leave=True, ascii=True, total=123) series = pd.Series(randint(0, 50, (100,)))