Hi @rzuckerm ,
Thanks for posting.
Both a pytest.ini
file and a pylintrc
file are available in our content repo.
As stated in the comments in Issue 2745, placing both files at the root of the project (i.e. the /python
folder) should make them discoverable to PyTest
and PyLint
, which will then pick them up for any exercise you complete. I think there may also be similar instructions under the Python Track Docs on the website.
After the files are in place (and you have navigated to a specific exercise folder), the PyTest
command would be pytest -v name_of_testfile_test.py
So running that on a Mac in the bash
shell in a (PY_3.11.5) virtual env for the Ghost Gobble Arcade Game
exercise looks like this (I am omitting all of the verbose PyTest failures):
(PY_3.11.5) pwd
/Users/__/exercism/python/exercises/concept/ghost-gobble-arcade-game
(PY_3.11.5) pytest -v arcade_game_test.py
platform darwin -- Python 3.11.5, pytest-7.4.3, pluggy-1.4.0 -- /usr/local/anaconda3/envs/PY_3.11.5/bin/python3.11
cachedir: .pytest_cache
rootdir: /Users/__/exercism/python
configfile: pytest.ini
plugins: subtests-0.11.0
collected 13 items
arcade_game_test.py::GhostGobbleGameTest::test_dont_lose_if_not_touching_a_ghost FAILED [ 7%]
arcade_game_test.py::GhostGobbleGameTest::test_dont_lose_if_touching_a_ghost_with_a_power_pellet_active FAILED [ 15%]
arcade_game_test.py::GhostGobbleGameTest::test_dont_win_if_all_dots_eaten_but_touching_a_ghost FAILED [ 23%]
arcade_game_test.py::GhostGobbleGameTest::test_dont_win_if_not_all_dots_eaten FAILED [ 30%]
arcade_game_test.py::GhostGobbleGameTest::test_ghost_does_not_get_eaten_because_no_power_pellet_active FAILED [ 38%]
arcade_game_test.py::GhostGobbleGameTest::test_ghost_does_not_get_eaten_because_not_touching_ghost FAILED [ 46%]
arcade_game_test.py::GhostGobbleGameTest::test_ghost_gets_eaten FAILED [ 53%]
arcade_game_test.py::GhostGobbleGameTest::test_lose_if_touching_a_ghost_without_a_power_pellet_active FAILED [ 61%]
arcade_game_test.py::GhostGobbleGameTest::test_no_score_when_nothing_eaten FAILED [ 69%]
arcade_game_test.py::GhostGobbleGameTest::test_score_when_eating_dot FAILED [ 76%]
arcade_game_test.py::GhostGobbleGameTest::test_score_when_eating_power_pellet FAILED [ 84%]
arcade_game_test.py::GhostGobbleGameTest::test_win_if_all_dots_eaten FAILED [ 92%]
arcade_game_test.py::GhostGobbleGameTest::test_win_if_all_dots_eaten_and_touching_a_ghost_with_a_power_pellet_active FAILED [100%]
The corresponding PyLint
command would be pylint name_of_codefile_to_lint.py
. Here it is for the same exercise (I ran it on the stub, so Pylint is very cranky):
(PY_3.11.5) pwd
/Users/__/exercism/python/exercises/concept/ghost-gobble-arcade-game
(PY_3.11.5) pylint arcade_game.py
************* Module arcade_game
arcade_game.py:27:0: C0301: Line too long (102/100) (line-too-long)
arcade_game.py:12:4: W0107: Unnecessary pass statement (unnecessary-pass)
arcade_game.py:4:14: W0613: Unused argument 'power_pellet_active' (unused-argument)
arcade_game.py:4:35: W0613: Unused argument 'touching_ghost' (unused-argument)
arcade_game.py:23:4: W0107: Unnecessary pass statement (unnecessary-pass)
arcade_game.py:15:10: W0613: Unused argument 'touching_power_pellet' (unused-argument)
arcade_game.py:15:33: W0613: Unused argument 'touching_dot' (unused-argument)
arcade_game.py:34:4: W0107: Unnecessary pass statement (unnecessary-pass)
arcade_game.py:26:9: W0613: Unused argument 'power_pellet_active' (unused-argument)
arcade_game.py:26:30: W0613: Unused argument 'touching_ghost' (unused-argument)
arcade_game.py:46:4: W0107: Unnecessary pass statement (unnecessary-pass)
arcade_game.py:37:8: W0613: Unused argument 'has_eaten_all_dots' (unused-argument)
arcade_game.py:37:28: W0613: Unused argument 'power_pellet_active' (unused-argument)
arcade_game.py:37:49: W0613: Unused argument 'touching_ghost' (unused-argument)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
We have not copied these config files into individual exercise folders for several reasons, the chief being that we would then have to update 288 files every time we needed to change configurations for the tools.
Having per-exercise config files also means more files to download for students, and it doesn’t help them learn how to configure Pytest or PyLint, which are generally set up to discover configurations files at the project level, with local overrides as needed.
While it is not ideal that students working locally have to do a manual one-time copy into the /python
folder, until we modify the Exercism CLI (see this discussion and this topic), its the cleanest (and least problematic for maintenance) we can do.
I’ll add reviewing the track docs to my list, and see if there is a way to clarify the setup a bit.
Unfortunately, unless you know Go (our CLI is written in Go-lang), the work that needs to be completed for this is the modification of the CLI to allow common files in the shared/
directory to be downloaded and copied into place for tracks.