Make tox the main unit test + Added more tests in tox

Signed-off-by: Stephen L. <lrq3000@gmail.com>
This commit is contained in:
Stephen L 2015-10-14 00:42:01 +02:00
parent f4c3b2bc1e
commit ec3d315d18
4 changed files with 60 additions and 35 deletions

View File

@ -36,36 +36,54 @@ TESTING
To test functionality on your machine (such as before submitting a Pull
Request), there are a number of unit tests.
To run the tests for only your Python distribution:
Standard unit testing
~~~~~~~~~~~~~~~~
The standard way to run the tests:
- install `tox`
- `cd` to the root of the `tqdm` directory (in the same folder as this file)
- run the following command:
```
make test
```
or
```
tox --skip-missing-interpreters
```
This will build the module and run the tests in a virtualized environment.
Wait a bit for tests to complete, and check the console/log for any error and
also check the coverage rate. Do not care about missing interpreters errors,
this is because tox tries to run the tests on several versions of Python and you
don't have them installed.
Note: to install all versions of the Python interpreter that are specified in
[tox.ini](tox.ini), 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 testing with Nose
~~~~~~~~~~~~~~~~~~~~~~~~~
Alternatively, you can use `nose` to run the tests just for your Python version:
- install `nose` and `flake8`
- run the following commands:
```
make alltests
```
Alternatively (if you can't use `make`)
- install `nosetest`
- run the following commands:
Or if you don't have `make`:
```
nosetests --with-coverage --cover-package=tqdm -v tqdm/
python -m flake8 tqdm/_tqdm.py
```
To run the tests for all Python distributions (better, but more time consuming):
- install `tox`
- install all versions of the Python interpreter that are specified in
[tox.ini](tox.ini). 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.
- `cd` to the root of the `tqdm` directory (in the same folder as this file)
- run the following command: `tox`
Then wait for the tests to finish, and check your console to see if there's
any issue.

View File

@ -8,6 +8,9 @@ flake8:
flake8 --max-line-length=80 --count --statistics --exit-zero examples/
test:
tox --skip-missing-interpreters
testnose:
nosetests tqdm -v
testsetup:
@ -16,8 +19,6 @@ testsetup:
testcoverage:
nosetests tqdm --with-coverage --cover-package=tqdm -v
allenvtests: tox
installdev:
python setup.py develop --uninstall
python setup.py develop

View File

@ -12,18 +12,18 @@ for i in trange(16, leave=True):
# Profiling/overhead tests
stmts = (
# Benchmark
'[i for i in xrange(int(1e8))]',
# Basic demo
'import tqdm; [i for i in tqdm.trange(int(1e8))]',
# Some decorations
'import tqdm; [i for i in tqdm.trange(int(1e8), miniters=int(1e6),'
' ascii=True, desc="cool")]',
# Experimental GUI demo
'import tqdm; [i for i in tqdm.trange(int(1e8), gui=True)]',
# Comparison to https://code.google.com/p/python-progressbar/
'from progressbar.progressbar import ProgressBar;'
' [i for i in ProgressBar()(xrange(int(1e8)))]')
# Benchmark
'[i for i in xrange(int(1e8))]',
# Basic demo
'import tqdm; [i for i in tqdm.trange(int(1e8))]',
# Some decorations
'import tqdm; [i for i in tqdm.trange(int(1e8), miniters=int(1e6),'
' ascii=True, desc="cool")]',
# Experimental GUI demo
'import tqdm; [i for i in tqdm.trange(int(1e8), gui=True)]',
# Comparison to https://code.google.com/p/python-progressbar/
'from progressbar.progressbar import ProgressBar;'
' [i for i in ProgressBar()(xrange(int(1e8)))]')
for s in stmts:
print s
print timeit(stmt=s, number=1), 'seconds'

10
tox.ini
View File

@ -17,7 +17,13 @@ commands =
coveralls
[testenv:flake8]
basepython = python2.7
deps = flake8
commands =
flake8 --count --statistics tqdm/
flake8 --max-line-length=80 --count --statistics --exit-zero tqdm/
flake8 --max-line-length=80 --count --statistics --exit-zero examples/
[testenv:setup.py]
deps =
docutils
commands =
python setup.py check --restructuredtext --metadata --strict