bitcraft / pyscroll

make scrolling games with animated maps in pygame
GNU General Public License v3.0
172 stars 28 forks source link

test_pyscroll Unit tests are failing #34

Closed oxzi closed 4 years ago

oxzi commented 4 years ago

The tests in the tests/unittests/test_pyscroll.py file seems to be outdated. Running the tests results in an error.

$ python -m unittest tests.unittests.test_pyscroll
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
EEEE
======================================================================
ERROR: test_queue_bottom (tests.unittests.test_pyscroll.TestTileQueue)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/pyscroll/tests/unittests/test_pyscroll.py", line 49, in test_queue_bottom
    self.queue(self.mock, 0, 1)
  File "/pyscroll/pyscroll/orthographic.py", line 420, in _queue_edge_tiles
    append((v.left, v.bottom - 1, v.width, dy))
  File "/pyscroll/pyscroll/orthographic.py", line 410, in append
    self._clear_surface(self._buffer, ((rect[0] - v.left) * tw, (rect[1] - v.top) * th,
AttributeError: 'DummyBufferer' object has no attribute '_clear_surface'

======================================================================

The next three tests will abort with the same error.

----------------------------------------------------------------------
Ran 4 tests in 0.001s

FAILED (errors=4)

After adding a _clear_surface function to the DummyBuffer, each test case will fail with the following error:

Traceback (most recent call last):
  File "/pyscroll/tests/unittests/test_pyscroll.py", line 51, in test_queue_bottom
    self.verify_queue({(2, 3), (3, 3)})
  File "/pyscroll/tests/unittests/test_pyscroll.py", line 34, in verify_queue
    queue = {i[:2] for i in self.mock._tile_queue}
  File "/pyscroll/tests/unittests/test_pyscroll.py", line 34, in <setcomp>
    queue = {i[:2] for i in self.mock._tile_queue}
  File "/pyscroll/pyscroll/data.py", line 275, in get_tile_images_by_rect
    tile = self.get_tile_image(x, y, layer)
TypeError: get_tile_image() takes 2 positional arguments but 4 were given

Am I holding it wrong or should the tests be updated? Thanks a lot.

bitcraft commented 4 years ago

The test suite is likely hopelessly out of date. Because its not difficult to test manually (maybe 5 minutes or less of my time), I run a few prepared maps before each release to check for regressions. Unit testing hasn't been a huge priority because the code base is small and regression testing is quick. I'm not really interested in updating the tests, but patches are welcome.

bitcraft commented 4 years ago

I see that you are doing something which depends on these tests. If this blocks you and you don't mind, you can submit a patch that will skip the tests that fail. Just add a comment that they are out of date and expected to fail.

bitcraft commented 4 years ago

Fixed tests