Skip to content

Commit

Permalink
bump version, merge branch 'devel'
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl committed Oct 25, 2020
2 parents 8f9e03d + 1807b49 commit 0f823e7
Show file tree
Hide file tree
Showing 30 changed files with 219 additions and 338 deletions.
2 changes: 1 addition & 1 deletion .coveragerc
@@ -1,7 +1,7 @@
[run]
branch = True
include = tqdm/*
omit =
tqdm/tests/*
tqdm/contrib/bells.py
tqdm/contrib/discord.py
tqdm/contrib/telegram.py
Expand Down
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -10,4 +10,4 @@ demo.yml @casperdcl @martinzugnoni
codecov.yml @lrq3000
setup.py @casperdcl @lrq3000
tqdm/_tqdm_notebook.py @lrq3000 @casperdcl
tqdm/tests/tests_pandas.py @casperdcl @chengs
tests/tests_pandas.py @casperdcl @chengs
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -14,8 +14,9 @@ tqdm_*_amd64.snap
# Unit test / coverage reports
.tox/
.coverage
__pycache__
nosetests.xml
.coverage.*
__pycache__/
.pytest_cache/

# Translations
*.mo
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: pypy2.7
python: pypy2.7-7.3.1
env: TOXENV=pypy
- name: pypy3.5
- name: pypy3.6
python: pypy3.6-7.3.1
env: TOXENV=pypy3
- stage: development
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Expand Up @@ -100,11 +100,11 @@ you can use `MiniConda` to install a minimal setup. You must also make sure
that each distribution has an alias to call the Python interpreter:
`python27` for Python 2.7's interpreter, `python32` for Python 3.2's, etc.

### Alternative unit tests with Nose
### Alternative unit tests with pytest

Alternatively, use `nose` to run the tests just for the current Python version:
Alternatively, use `pytest` to run the tests just for the current Python version:

- install `nose` and `flake8`
- install `pytest` and `flake8`
- run the following command:

```
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Expand Up @@ -11,7 +11,7 @@ include tox.ini
recursive-include tqdm/contrib *.py

# Test suite
recursive-include tqdm/tests *.py
recursive-include tests *.py
include requirements-dev.txt

# Examples/Documentation
Expand Down
25 changes: 13 additions & 12 deletions Makefile
Expand Up @@ -8,7 +8,7 @@
all
flake8
test
testnose
pytest
testsetup
testcoverage
testperf
Expand Down Expand Up @@ -50,8 +50,8 @@ test:
TOX_SKIP_ENV=perf tox --skip-missing-interpreters -p all
tox -e perf

testnose:
nosetests -d -v tqdm
pytest:
pytest

testsetup:
@make README.rst
Expand All @@ -62,14 +62,14 @@ testsetup:

testcoverage:
@make coverclean
nosetests -d -v tqdm --ignore-files="tests_perf\.py" --with-coverage --cover-package=tqdm --cover-erase --cover-min-percentage=80
pytest -k "not tests_perf" --cov=tqdm --cov-fail-under=80

testperf:
# do not use coverage (which is extremely slow)
nosetests -d -v tqdm/tests/tests_perf.py
pytest -k tests_perf

testtimer:
nosetests -d -v tqdm --with-timer
pytest --durations=10

# another performance test, to check evolution across commits
testasv:
Expand Down Expand Up @@ -119,24 +119,25 @@ distclean:
@+make clean
pre-commit:
# quick sanity checks
@make testsetup
flake8 -j 8 --count --statistics tqdm/ examples/
nosetests -d tqdm --ignore-files="tests_(perf|keras)\.py" -e "pandas|monitoring"
nosetests -d tqdm/tests/tests_perf.py -m basic_overhead
@make --no-print-directory testsetup
flake8 -j 8 --count --statistics tqdm/ tests/ examples/
pytest -qq -k "basic_overhead or not (perf or keras or pandas or monitoring)"
prebuildclean:
@+python -c "import shutil; shutil.rmtree('build', True)"
@+python -c "import shutil; shutil.rmtree('dist', True)"
@+python -c "import shutil; shutil.rmtree('tqdm.egg-info', True)"
coverclean:
@+python -c "import os; os.remove('.coverage') if os.path.exists('.coverage') else None"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('.coverage.*')]"
@+python -c "import shutil; shutil.rmtree('tests/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('tqdm/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('tqdm/contrib/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('tqdm/tests/__pycache__', True)"
@+python -c "import shutil; shutil.rmtree('tqdm/examples/__pycache__', True)"
clean:
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tests/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/contrib/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/tests/*.py[co]')]"
@+python -c "import os, glob; [os.remove(i) for i in glob.glob('tqdm/examples/*.py[co]')]"
toxclean:
@+python -c "import shutil; shutil.rmtree('.tox', True)"
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -433,7 +433,7 @@ Parameters
percentage, elapsed, elapsed_s, ncols, nrows, desc, unit,
rate, rate_fmt, rate_noinv, rate_noinv_fmt,
rate_inv, rate_inv_fmt, postfix, unit_divisor,
remaining, remaining_s.
remaining, remaining_s, eta.
Note that a trailing ": " is automatically removed after {desc}
if the latter is empty.
* initial : int or float, optional
Expand Down
6 changes: 6 additions & 0 deletions setup.cfg
Expand Up @@ -5,3 +5,9 @@ universal = 1
ignore = W503,W504,E722
max_line_length = 80
exclude = .asv,.tox,.ipynb_checkpoints,build,dist,.git,__pycache__

[tool:pytest]
python_files = tests_*.py
testpaths = tests
addopts = -v --tb=short
usefixtures = pretest_posttest
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -121,6 +121,6 @@ def find_packages(where='.'):
],
keywords='progressbar progressmeter progress bar meter'
' rate eta console terminal time',
test_suite='nose.collector',
tests_require=['nose', 'flake8', 'coverage'],
test_suite='pytest',
tests_require=['pytest', 'flake8', 'coverage'],
)
Empty file added tests/__init__.py
Empty file.
6 changes: 3 additions & 3 deletions tqdm/tests/py37_asyncio.py → tests/py37_asyncio.py
@@ -1,17 +1,17 @@
import asyncio
from functools import partial, wraps
from time import time
import asyncio

from tests_tqdm import with_setup, pretest, posttest, StringIO, closing
from tqdm.asyncio import tqdm_asyncio, tarange
from .tests_tqdm import pretest_posttest # NOQA, pylint: disable=unused-import
from .tests_tqdm import StringIO, closing

tqdm = partial(tqdm_asyncio, miniters=0, mininterval=0)
trange = partial(tarange, miniters=0, mininterval=0)
as_completed = partial(tqdm_asyncio.as_completed, miniters=0, mininterval=0)


def with_setup_sync(func):
@with_setup(pretest, posttest)
@wraps(func)
def inner():
return asyncio.run(func())
Expand Down
11 changes: 11 additions & 0 deletions tests/tests_asyncio.py
@@ -0,0 +1,11 @@
"""Tests `tqdm.asyncio` on `python>=3.7`."""
import sys

if sys.version_info[:2] > (3, 6):
from .py37_asyncio import * # NOQA, pylint: disable=wildcard-import
else:
import pytest
try:
pytest.skip("async not supported", allow_module_level=True)
except TypeError:
pass
20 changes: 8 additions & 12 deletions tqdm/tests/tests_concurrent.py → tests/tests_concurrent.py
Expand Up @@ -2,47 +2,43 @@
Tests for `tqdm.contrib.concurrent`.
"""
from warnings import catch_warnings

from tqdm.contrib.concurrent import thread_map, process_map
from tests_tqdm import with_setup, pretest, posttest, SkipTest, StringIO, \
closing
from .tests_tqdm import pretest_posttest # NOQA, pylint: disable=unused-import
from .tests_tqdm import importorskip, skip, StringIO, closing


def incr(x):
"""Dummy function"""
return x + 1


@with_setup(pretest, posttest)
def test_thread_map():
"""Test contrib.concurrent.thread_map"""
with closing(StringIO()) as our_file:
a = range(9)
b = [i + 1 for i in a]
try:
assert thread_map(lambda x: x + 1, a, file=our_file) == b
except ImportError:
raise SkipTest
except ImportError as err:
skip(str(err))
assert thread_map(incr, a, file=our_file) == b


@with_setup(pretest, posttest)
def test_process_map():
"""Test contrib.concurrent.process_map"""
with closing(StringIO()) as our_file:
a = range(9)
b = [i + 1 for i in a]
try:
assert process_map(incr, a, file=our_file) == b
except ImportError:
raise SkipTest
except ImportError as err:
skip(str(err))


def test_chunksize_warning():
"""Test contrib.concurrent.process_map chunksize warnings"""
try:
from unittest.mock import patch
except ImportError:
raise SkipTest
patch = importorskip("unittest.mock").patch

for iterables, should_warn in [
([], False),
Expand Down
14 changes: 4 additions & 10 deletions tqdm/tests/tests_contrib.py → tests/tests_contrib.py
Expand Up @@ -2,17 +2,17 @@
Tests for `tqdm.contrib`.
"""
import sys

from tqdm.contrib import tenumerate, tzip, tmap
from tests_tqdm import with_setup, pretest, posttest, SkipTest, StringIO, \
closing
from .tests_tqdm import pretest_posttest # NOQA, pylint: disable=unused-import
from .tests_tqdm import importorskip, StringIO, closing


def incr(x):
"""Dummy function"""
return x + 1


@with_setup(pretest, posttest)
def test_enumerate():
"""Test contrib.tenumerate"""
with closing(StringIO()) as our_file:
Expand All @@ -27,19 +27,14 @@ def test_enumerate():
assert "100%" in our_file.getvalue()


@with_setup(pretest, posttest)
def test_enumerate_numpy():
"""Test contrib.tenumerate(numpy.ndarray)"""
try:
import numpy as np
except ImportError:
raise SkipTest
np = importorskip("numpy")
with closing(StringIO()) as our_file:
a = np.random.random((42, 1337))
assert list(tenumerate(a, file=our_file)) == list(np.ndenumerate(a))


@with_setup(pretest, posttest)
def test_zip():
"""Test contrib.tzip"""
with closing(StringIO()) as our_file:
Expand All @@ -53,7 +48,6 @@ def test_zip():
assert list(gen) == list(zip(a, b))


@with_setup(pretest, posttest)
def test_map():
"""Test contrib.tmap"""
with closing(StringIO()) as our_file:
Expand Down
7 changes: 4 additions & 3 deletions tqdm/tests/tests_itertools.py → tests/tests_itertools.py
@@ -1,10 +1,12 @@
"""
Tests for `tqdm.contrib.itertools`.
"""
from tqdm.contrib.itertools import product
from tests_tqdm import with_setup, pretest, posttest, StringIO, closing
import itertools

from tqdm.contrib.itertools import product
from .tests_tqdm import pretest_posttest # NOQA, pylint: disable=unused-import
from .tests_tqdm import StringIO, closing


class NoLenIter(object):
def __init__(self, iterable):
Expand All @@ -15,7 +17,6 @@ def __iter__(self):
yield i


@with_setup(pretest, posttest)
def test_product():
"""Test contrib.itertools.product"""
with closing(StringIO()) as our_file:
Expand Down
17 changes: 7 additions & 10 deletions tqdm/tests/tests_keras.py → tests/tests_keras.py
@@ -1,21 +1,18 @@
from __future__ import division

from tqdm import tqdm
from tests_tqdm import with_setup, pretest, posttest, SkipTest, StringIO, \
closing
from .tests_tqdm import pretest_posttest # NOQA, pylint: disable=unused-import
from .tests_tqdm import importorskip, StringIO, closing


@with_setup(pretest, posttest)
def test_keras():
"""Test tqdm.keras.TqdmCallback"""
TqdmCallback = importorskip("tqdm.keras").TqdmCallback
np = importorskip("numpy")
try:
from tqdm.keras import TqdmCallback
import numpy as np
try:
import keras as K
except ImportError:
from tensorflow import keras as K
import keras as K
except ImportError:
raise SkipTest
K = importorskip("tensorflow.keras")

# 1D autoencoder
dtype = np.float32
Expand Down

0 comments on commit 0f823e7

Please sign in to comment.