Closed sweep-mine[bot] closed 10 months ago
tests/test_snake.py
✓
Sandbox logs for https://github.com/eranheres/cli_snake_game_self/commit/cff7cebbb4f2f2a15356be21f90a87a98387fdd5
trunk fmt tests/test_snake.py || return 0
1/2 ✓✔ Formatted tests/test_snake.py Re-checking autofixed files... ✔ Formatted tests/test_snake.py Re-checking autofixed files... Checked 1 file ✔ No issues Run trunk upgrade to upgrade 1 linter
trunk check --fix --print-failures tests/test_snake.py
2/2 ✓Checked 1 file ✔ No issues
The command:
Run pytest
yielded the following error:
##[error]Process completed with exit code 1.
Here are the logs:
============================= test session starts ==============================
platform linux -- Python 3.10.13, pytest-7.4.3, pluggy-1.3.0
rootdir: /home/runner/work/cli_snake_game_self/cli_snake_game_self
collected 11 items
pytest/test_empty.py . [ 9%]
tests/test_empty.py . [ 18%]
tests/test_food.py ... [ 45%]
tests/test_snake.py ..F... [100%]
=================================== FAILURES ===================================
_____________________________ TestSnake.test_init ______________________________
self = <tests.test_snake.TestSnake testMethod=test_init>
def test_init(self):
s = snake.Snake()
> self.assertEqual(s.body, [(40, 40), (30, 40), (20, 40)])
E AssertionError: Lists differ: [(40, 40), (30, 40), (20, 40), (20, 40)] != [(40, 40), (30, 40), (20, 40)]
E
E First list contains 1 additional elements.
E First extra element 3:
E (20, 40)
E
E - [(40, 40), (30, 40), (20, 40), (20, 40)]
E ? ----------
E
E + [(40, 40), (30, 40), (20, 40)]
tests/test_snake.py:9: AssertionError
=========================== short test summary info ============================
FAILED tests/test_snake.py::TestSnake::test_init - AssertionError: Lists differ: [(40, 40), (30, 40), (20, 40), (20, 40)] != [(40, 40), (30, 40), (20, 40)]
First list contains 1 additional elements.
First extra element 3:
(20, 40)
- [(40, 40), (30, 40), (20, 40), (20, 40)]
? ----------
+ [(40, 40), (30, 40), (20, 40)]
========================= 1 failed, 10 passed in 0.06s =========================
I wasn't able to make changes. This could be due to an unclear request or a bug in my code. As a reminder, comments on a file only modify that file. Comments on a PR (at the bottom of the "conversation" tab) can modify the entire PR. Please try again or contact us on Discord
Description
This PR adds unit tests for the
snake.py
file to ensure the correctness of the Snake and Food classes' methods.Summary of Changes
tests/test_snake.py
to contain unit tests for thesnake.py
file.Fixes #28.
🎉 Latest improvements to Sweep:
rope
library to refactor Python! Check out Large Language Models are Bad at Refactoring Code. To have Sweep refactor your code, trysweep: Refactor <your_file>.py
!💡 To get Sweep to edit this pull request, you can: