unit tests for #364

- closes #535
This commit is contained in:
Guangshuo CHEN 2018-04-12 12:13:50 +02:00 committed by Casper da Costa-Luis
parent b502f0d961
commit 1cc3005f9c
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
1 changed files with 24 additions and 0 deletions

View File

@ -1,8 +1,32 @@
from nose.plugins.skip import SkipTest
import warnings
from tqdm import tqdm
from tests_tqdm import with_setup, pretest, posttest, StringIO, closing
@with_setup(pretest, posttest)
def test_pandas_setup():
"""Test tqdm.pandas()"""
try:
from numpy.random import randint
import pandas as pd
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,)))
series.progress_apply(lambda x: x + 10)
res = our_file.getvalue()
assert '100/123' in res
@with_setup(pretest, posttest)
def test_pandas_series():