diff --git a/.circleci/config.yml b/.circleci/config.yml index 1370bc61..8f34650f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,13 +5,12 @@ my-steps: &steps - run: sudo pip install -r requirements.txt - run: sudo pip install flake8 pytest - run: python --version ; pip --version ; pwd ; ls -l + - run: pip install --user . # stop the build if there are Python syntax errors or undefined names - run: flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - run: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics - #- run: pytest # test_s2gs test_replays - - run: python -m unittest discover test_s2gs - - run: python -m unittest discover test_replays + - run: pytest jobs: Python2: diff --git a/README.rst b/README.rst index ca2dfb3e..fa78c025 100644 --- a/README.rst +++ b/README.rst @@ -259,21 +259,36 @@ Please review the `CONTRIBUTING.md`_ file and get in touch with us before doing Testing ------------------- -We use the built in ``unittest`` module for testing. If you are still on Python 2.6 you will need to install ``unittest2`` because our test suite requires newer features than are included in the main distribution. +We use ``pytest`` for testing. If you don't have it just ``pip install pytest``. -To run the tests just use:: +To run the tests, just do:: - python test_replays/test_all.py - python test_s2gs/test_all.py + pytest -When repeatedly running tests it can be very helpful to make sure you've set a local cache directory to prevent long fetch times from battle.net:: - SC2READER_CACHE_DIR=local_cache PYTHONPATH=. python -m unittest test_replays.test_all +When repeatedly running tests it can be very helpful to make sure you've set a local cache directory to prevent long fetch times from battle.net. +So make some local cache folder:: + + mkdir cache + +And then run the tests like this:: + + SC2READER_CACHE_DIR=./cache pytest To run just one test: - SC2READER_CACHE_DIR=local_cache PYTHONPATH=. python -m unittest test_replays.test_all.TestReplays.test_38749 + SC2READER_CACHE_DIR=./cache pytest test_replays/test_replays.py::TestReplays::test_38749 + +If you'd like to see which are the 10 slowest tests (to find performance issues maybe):: + + pytest --durations=10 + +If you want ``pytest`` to stop after the first failing test:: + + pytest -x + +Have a look at the very fine ``pytest`` docs for more information. Good luck, have fun! diff --git a/setup.py b/setup.py index c5d1d694..d067af22 100644 --- a/setup.py +++ b/setup.py @@ -48,6 +48,7 @@ }, install_requires=['mpyq>=0.2.3', 'argparse', 'ordereddict', 'unittest2', 'pil'] if float(sys.version[:3]) < 2.7 else ['mpyq>=0.2.4'], + tests_require=["pytest"], packages=setuptools.find_packages(), include_package_data=True, zip_safe=True diff --git a/test_replays/test_all.py b/test_replays/test_replays.py similarity index 100% rename from test_replays/test_all.py rename to test_replays/test_replays.py