eranheres / cli_snake_game_self

0 stars 0 forks source link

Add unit tests for snake.py #29

Closed sweep-mine[bot] closed 10 months ago

sweep-mine[bot] commented 10 months ago

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

Fixes #28.


🎉 Latest improvements to Sweep:


💡 To get Sweep to edit this pull request, you can:

sweep-mine[bot] commented 10 months ago

Sandbox Executions

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

sweep-mine[bot] commented 10 months ago

Apply Sweep Rules to your PR?

sweep-mine[bot] commented 10 months ago

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 =========================
sweep-mine[bot] commented 10 months ago

🚀 Wrote Changes

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