Errors in tests: Expected and Actual swapped

  1. Please use codeblocks (text) to share text, not images.
  2. How are you running the tests?

I run tests from JetBrains IDE

/usr/bin/python3 /Users/jcemisovs/Applications/PyCharm.app/Contents/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py --target grains_test.py::GrainsTest 
Testing started at 20:23 ...
Launching pytest with arguments grains_test.py::GrainsTest --no-header --no-summary -q in /Users/jcemisovs/Exercism/python/grains

============================= test session starts ==============================
collecting ... collected 11 items

grains_test.py::GrainsTest::test_grains_on_square_1 PASSED               [  9%]
grains_test.py::GrainsTest::test_grains_on_square_16 PASSED              [ 18%]
grains_test.py::GrainsTest::test_grains_on_square_2 PASSED               [ 27%]
grains_test.py::GrainsTest::test_grains_on_square_3 PASSED               [ 36%]
grains_test.py::GrainsTest::test_grains_on_square_32 PASSED              [ 45%]
grains_test.py::GrainsTest::test_grains_on_square_4 PASSED               [ 54%]
grains_test.py::GrainsTest::test_grains_on_square_64 PASSED              [ 63%]
grains_test.py::GrainsTest::test_negative_square_is_invalid PASSED       [ 72%]
grains_test.py::GrainsTest::test_returns_the_total_number_of_grains_on_the_board FAILED [ 81%]
grains_test.py:52 (GrainsTest.test_returns_the_total_number_of_grains_on_the_board)
18446744073709551615 != 36893488147419103231

Expected :36893488147419103231
Actual   :18446744073709551615
<Click to see difference>

self = <grains_test.GrainsTest testMethod=test_returns_the_total_number_of_grains_on_the_board>

    def test_returns_the_total_number_of_grains_on_the_board(self):
>       self.assertEqual(total(), 18446744073709551615)

grains_test.py:54: AssertionError

grains_test.py::GrainsTest::test_square_0_is_invalid PASSED              [ 90%]
grains_test.py::GrainsTest::test_square_greater_than_64_is_invalid PASSED [100%]

========================= 1 failed, 10 passed in 0.02s =========================

Process finished with exit code 1

Hi @rabestro :wave:

Please take a look at this thread from early 2023 and this thread from later in 2023.

If you are using PyCharm/Jetbrains, results will indeed look “reversed”. But the bug is with PyCharm/Jetbrains, and not the tests.

2 Likes

You might be able to configure JetBrains to run pytest instead to run the tests.

I was just getting ready to type this out! You can indeed invoke a terminal from PyCharm, and use that to directly run PyTest and get results — so you don’t have to go out to a separate bash or zsh terminal to do it, and can get results inside the IDE (just not via the IDE menue or interface).

I think you might even be able to make a macro that would do those things on file save. I haven’t done that for my version of PyCharm, but I suspect it is fairly straightforward to work out.