From 9f7342341b8f2c3efb404350b12e3fa7704ccb68 Mon Sep 17 00:00:00 2001 From: Kyle Nied Date: Sun, 6 Aug 2017 13:20:55 -0400 Subject: [PATCH 1/5] Update TESTS.md Provides information on the different types of "pytest" available, as well as switched "py.test" to "pytest", as recommended here (https://github.com/pytest-dev/pytest/issues/1629#issue-161422224). --- docs/TESTS.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index 53ea9ddf3f..a2b8e16d7a 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -4,9 +4,17 @@ We recommend you install [pytest](http://pytest.org/latest/) and [pytest-cache](http://pythonhosted.org/pytest-cache/). `pytest` is a testing tool that will give you more flexibility over running your unit tests. +If you want to install the version of pytest that obeys Python 2.X syntax, then use `pip`: + ```bash pip install pytest pytest-cache ``` +If you instead want the vesrion of pytest that obeys Python 3.X syntax, then use `pip3`: + +```bash +pip3 install pytest pytest-cache +``` +**Note:** Whichever version of pytest you install first will be the default one used. If you get a `command not found` response from your system, you can find a tutorial on how to install `pip` @@ -29,7 +37,7 @@ an example here), place yourself in the directory where that exercise has been fetched and run: ```bash -py.test bob_test.py +pytest bob_test.py ``` **Note:** To run the tests you need to pass the name of the testsuite file to @@ -56,7 +64,7 @@ The above will run all the tests, whether they fail or not. If you'd rather stop the process and exit on the first failure, run: ```bash -py.test -x bob_test.py +pytest -x bob_test.py ``` ### Failed Tests First @@ -64,14 +72,14 @@ py.test -x bob_test.py `pytest-cache` remembers which tests failed, and can run those tests first. ```bash -py.test --ff bob_test.py +pytest --ff bob_test.py ``` ### Running All Tests for All Exercises ```bash cd exercism/python/ -py.test +pytest ``` ## Recommended Workflow @@ -80,7 +88,7 @@ We recommend you run this command while working on exercises. ```bash cd exercism/python/bob -py.test -x --ff bob_test.py +pytest -x --ff bob_test.py ``` ## PDB @@ -93,7 +101,7 @@ You may also be interested in watching [Clayton Parker's "So you think you can pdb?" PyCon 2015 talk](https://www.youtube.com/watch?v=P0pIW5tJrRM) ```bash -py.test --pdb bob_test.py +pytest --pdb bob_test.py ``` ## PEP8 @@ -107,10 +115,16 @@ compliance to the style guide, install pip install pytest-pep8 ``` +or, for Python 3.X syntax compliance... + +```bash +pip install pytest-pep8 +``` + and add the pep8 flag to your command ```bash -py.test --pep8 bob_test.py +pytest --pep8 bob_test.py ``` Read the [pytest documentation](http://pytest.org/latest/contents.html#toc) and From 5adc1822abe04d85fe69d792be9dbc2fb6aa3e01 Mon Sep 17 00:00:00 2001 From: Kyle Nied Date: Mon, 21 Aug 2017 21:48:56 -0400 Subject: [PATCH 2/5] Fixed a typo. --- docs/TESTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index a2b8e16d7a..2492a38674 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -118,7 +118,7 @@ pip install pytest-pep8 or, for Python 3.X syntax compliance... ```bash -pip install pytest-pep8 +pip3 install pytest-pep8 ``` and add the pep8 flag to your command From 1c90592faa52f33b1c6a81bf218423d566cc2be9 Mon Sep 17 00:00:00 2001 From: Kyle Nied Date: Sun, 8 Oct 2017 19:55:57 -0400 Subject: [PATCH 3/5] Small edit. --- docs/TESTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index 2492a38674..7b94ab4fa9 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -14,7 +14,7 @@ If you instead want the vesrion of pytest that obeys Python 3.X syntax, then use ```bash pip3 install pytest pytest-cache ``` -**Note:** Whichever version of pytest you install first will be the default one used. +**Note:** Whichever version of pytest you install first will be the default one used whenever `pytest` is executed, regardless of whether you have installed both versions. If you get a `command not found` response from your system, you can find a tutorial on how to install `pip` From 7ab610921098bd62f35ebe34b928eb8512d4fce2 Mon Sep 17 00:00:00 2001 From: Kyle Nied Date: Mon, 23 Oct 2017 20:14:20 -0400 Subject: [PATCH 4/5] Update TESTS.md Cleaned it up, addressed what user "N-Parsons" commented on, fixed some errors, and added new information. --- docs/TESTS.md | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index 7b94ab4fa9..0c986a185e 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -4,22 +4,38 @@ We recommend you install [pytest](http://pytest.org/latest/) and [pytest-cache](http://pythonhosted.org/pytest-cache/). `pytest` is a testing tool that will give you more flexibility over running your unit tests. -If you want to install the version of pytest that obeys Python 2.X syntax, then use `pip`: +If you want to install `pytest` for Python 2, then use `pip`. ```bash pip install pytest pytest-cache ``` -If you instead want the vesrion of pytest that obeys Python 3.X syntax, then use `pip3`: +If you instead want the version of `pytest` for Python 3, then use `pip3`. ```bash pip3 install pytest pytest-cache ``` -**Note:** Whichever version of pytest you install first will be the default one used whenever `pytest` is executed, regardless of whether you have installed both versions. If you get a `command not found` response from your system, you can find a tutorial on how to install `pip` [here](https://pip.pypa.io/en/stable/installing/). +**Note:** Whichever version of `pytest` you install last will be the default one used whenever `pytest` is executed, regardless of whether you have installed both versions. + +If you want to check what the default version of `pytest` being used is, run the following: + +```bash +pytest --version +``` + +If you have either version of `pytest` installed and you want to specifically run one of the versions, you can run that version by using `python` with the `-m` flag. + +For example, you could run the Python 3 version of pytest like so: + +```bash +$ python3 -m pytest --version +This is pytest version 3.2.3, imported from /usr/local/lib/python3.5/dist-packages/pytest.py +``` + If you choose not to install `pytest`, you can still run tests individually and skip the rest of this tutorial: @@ -109,19 +125,13 @@ pytest --pdb bob_test.py PEP8 is the [Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/). If you would like to test for compliance to the style guide, install -[pytest-pep8](https://pypi.python.org/pypi/pytest-pep8) +[pytest-pep8](https://pypi.python.org/pypi/pytest-pep8). ```bash pip install pytest-pep8 ``` -or, for Python 3.X syntax compliance... - -```bash -pip3 install pytest-pep8 -``` - -and add the pep8 flag to your command +Then, just add the `--pep8` flag to your command ```bash pytest --pep8 bob_test.py From 442ae2ea475c3e5d320c0fe2e18d93fa74ddc88f Mon Sep 17 00:00:00 2001 From: Kyle Nied Date: Mon, 23 Oct 2017 20:29:38 -0400 Subject: [PATCH 5/5] Small Change to "PDB" Section. --- docs/TESTS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/TESTS.md b/docs/TESTS.md index 0c986a185e..697282a158 100644 --- a/docs/TESTS.md +++ b/docs/TESTS.md @@ -113,13 +113,13 @@ Will drop you into the python debugger when a test fails. To learn how to use pdb, check out the [documentation](https://docs.python.org/3/library/pdb.html#debugger-commands). -You may also be interested in watching [Clayton Parker's "So you think you can -pdb?" PyCon 2015 talk](https://www.youtube.com/watch?v=P0pIW5tJrRM) - ```bash pytest --pdb bob_test.py ``` +You may also be interested in watching [Clayton Parker's "So you think you can +pdb?" PyCon 2015 talk](https://www.youtube.com/watch?v=P0pIW5tJrRM). + ## PEP8 PEP8 is the [Style Guide for Python