tests: warnings and timeout

This commit is contained in:
Casper da Costa-Luis 2021-01-03 22:02:40 +00:00
parent 67130a2364
commit 841090491a
No known key found for this signature in database
GPG Key ID: 986B408043AE090D
6 changed files with 18 additions and 10 deletions

View File

@ -17,6 +17,7 @@ dependencies:
# tests (native)
- pytest
- pytest-cov
- pytest-timeout
- pytest-asyncio # [py>=3.7]
- flake8
- coverage

View File

@ -16,9 +16,11 @@ split_before_named_assigns=False
split_before_closing_bracket=False
[tool:pytest]
timeout=30
log_level=INFO
python_files=tests_*.py
testpaths=tests
addopts=-v --tb=short -rxs --durations=0 --durations-min=0.1
addopts=-v --tb=short -rxs -W=error --durations=0 --durations-min=0.1
[metadata]
name = tqdm

View File

@ -1,12 +1,10 @@
"""
Tests for `tqdm.contrib.concurrent`.
"""
from warnings import catch_warnings
from pytest import mark
from pytest import mark, warns
from tqdm.contrib.concurrent import thread_map, process_map
from .tests_tqdm import importorskip, skip, StringIO, closing
from .tests_tqdm import importorskip, skip, StringIO, closing, TqdmWarning
def incr(x):
@ -44,6 +42,7 @@ def test_chunksize_warning(iterables, should_warn):
"""Test contrib.concurrent.process_map chunksize warnings"""
patch = importorskip("unittest.mock").patch
with patch('tqdm.contrib.concurrent._executor_map'):
with catch_warnings(record=True) as w:
if should_warn:
warns(TqdmWarning, process_map, incr, *iterables)
else:
process_map(incr, *iterables)
assert should_warn == bool(w)

View File

@ -1,9 +1,12 @@
from __future__ import division
from pytest import mark
from tqdm import tqdm
from .tests_tqdm import importorskip, StringIO, closing
@mark.filterwarnings("ignore:.*:DeprecationWarning")
def test_keras():
"""Test tqdm.keras.TqdmCallback"""
TqdmCallback = importorskip("tqdm.keras").TqdmCallback

View File

@ -18,6 +18,7 @@ commands=
deps =
pytest
pytest-cov
pytest-timeout
py{37,38,39}: pytest-asyncio
coverage
coveralls
@ -41,7 +42,7 @@ allowlist_externals = {[extra]allowlist_externals}
[testenv:py{27,py2}{,-tf}{,-keras}]
commands =
pytest --cov=tqdm --cov-report=xml --cov-report=term -k "not tests_perf" -o addopts= -v --tb=short -rxs --durations=10
pytest --cov=tqdm --cov-report=xml --cov-report=term -k "not tests_perf" -o addopts= -v --tb=short -rxs -W=error --durations=10
{[coverage]commands}
# no cython/numpy/pandas
@ -49,7 +50,9 @@ commands =
deps = {[extra]deps}
[testenv:perf]
deps = pytest
deps =
pytest
pytest-timeout
commands = pytest -k tests_perf
[testenv:flake8]

View File

@ -712,7 +712,7 @@ class tqdm(Comparable):
from pandas.core.window.rolling import Rolling
from pandas.core.window.expanding import Expanding
_Rolling_and_Expanding = Rolling, Expanding
except ImportError:
except ImportError: # pragma: no cover
_Rolling_and_Expanding = None
try: # pandas>=0.25.0
from pandas.core.groupby.generic import DataFrameGroupBy, \