diff --git a/docs/source/contribution.rst b/docs/source/contribution.rst index 87074b2efc49..7562b2c14030 100644 --- a/docs/source/contribution.rst +++ b/docs/source/contribution.rst @@ -286,40 +286,42 @@ Unit Testing Testing is one of the most important part of your code. You must write test cases and verify your implementation by following our testing guide. -Note that we are using nose and mock package for testing, so install them before writing your code:: +Note that we are using pytest and mock package for testing, so install them before writing your code:: - $ pip install nose mock + $ pip install pytest mock How to Run Tests ~~~~~~~~~~~~~~~~ -You can run unit tests simply by running ``nosetests`` command at the repository root:: +You can run unit tests simply by running ``python -m pytest`` command at the repository root:: - $ nosetests + $ python -m pytest or specify the test script that you want to run:: - $ nosetests path/to/your/test.py + $ python -m pytest path/to/your/test.py You can also run all unit tests under a specified directory:: - $ nosetests tests/chainer_tests/ + $ python -m pytest tests/chainer_tests/ -It requires CUDA by default. -In order to run unit tests that do not require CUDA, pass ``--attr='!gpu'`` option to the ``nosetests`` command:: +It requires CUDA and cuDNN by default. +In order to run unit tests that do not require CUDA and cuDNN, use ``CHAINER_TEST_GPU_LIMIT=0`` environment variable and ``-m='not cudnn'`` option:: - $ nosetests path/to/your/test.py --attr='!gpu' + $ export CHAINER_TESITNG_GPU_LIMIT=0 + $ python -m pytest path/to/your/test.py -m='not cudnn' Some GPU tests involve multiple GPUs. -If you want to run GPU tests with insufficient number of GPUs, specify the number of available GPUs by ``--eval-attr='gpu`_. + If you want to specify more than two attributes, use ``and`` operator like ``-m='not cudnn and not slow'``. + See detail in `the document of pytest `_. -Once you send a pull request, your code is automatically tested by `Travis-CI `_ **with --attr='!gpu,!slow' option**. +Once you send a pull request, your code is automatically tested by `Travis-CI `_ **except for tests annotated with ``gpu``, ``multi_gpu`` and ``slow``**. Since Travis-CI does not support CUDA, we cannot check your CUDA-related code automatically. The reviewing process starts after the test passes. Note that reviewers will test your code without the option to check CUDA-related code.