Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup e2e test with 20 rounds #83

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

miketwo
Copy link
Collaborator

@miketwo miketwo commented Oct 9, 2024

I've increased the end to end test to 20 rounds. On my machine, 15 of them fail. We can use this PR to fix them.

Current failures:

=========================== short test summary info ============================
FAILED tests/test_game.py::test_e2e[4] - AttributeError: 'NoneType' object ha...
FAILED tests/test_game.py::test_e2e[5] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[6] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[8] - AttributeError: 'NoneType' object ha...
FAILED tests/test_game.py::test_e2e[9] - AttributeError: 'NoneType' object ha...
FAILED tests/test_game.py::test_e2e[10] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[11] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[12] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[13] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[14] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[15] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[16] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[17] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[18] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[19] - AttributeError: 'NoneType' object h...
======================== 15 failed, 5 passed in 41.26s =========================

Details on one of those errors:

tests/test_game.py:114: in test_e2e
    mygame.start()
game.py:29: in start
    self.play(encounter, self.game_map)
game.py:47: in play
    retval = self.current_encounter.combat()
combat.py:50: in combat
    view.display_ui(self.player, self.active_enemies)
displayer.py:77: in display_ui
    view_piles(entity.hand, entity, False, lambda card: (card.energy_cost if card.energy_cost != -1 else entity.energy) <= entity.energy)
displayer.py:32: in view_piles
    if validator(card):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

card = None

>   view_piles(entity.hand, entity, False, lambda card: (card.energy_cost if card.energy_cost != -1 else entity.energy) <= entity.energy)
E   AttributeError: 'NoneType' object has no attribute 'energy_cost'

displayer.py:77: AttributeError

Any ideas?

@vesper-arch
Copy link
Owner

Looks like somehow None is somehow making it into the player's hand?? I'll have to take a closer look once I get back from school

@miketwo
Copy link
Collaborator Author

miketwo commented Oct 10, 2024

If you just run test number 4, this is the last bit of output before the failure:
image

This avoids tests polluting each other
Priority from 1 to 100, with 1 being highest
@miketwo
Copy link
Collaborator Author

miketwo commented Oct 11, 2024

It looked strange that all the tests were failing with the same thing after the first failure, and it was because the MessageBus was not being reset between games. So I fixed that. I also added a priority argument so that subscribers could make sure they're called first or last or whatever.

The new failures on my machine:

=========================== short test summary info ============================
FAILED tests/test_game.py::test_e2e[2] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[4] - AttributeError: 'NoneType' object ha...
FAILED tests/test_game.py::test_e2e[5] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[6] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[8] - AttributeError: 'NoneType' object ha...
FAILED tests/test_game.py::test_e2e[10] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[14] - AttributeError: 'NoneType' object h...
FAILED tests/test_game.py::test_e2e[17] - Failed: Timeout >10.0s
FAILED tests/test_game.py::test_e2e[19] - Failed: Timeout >10.0s
=================== 9 failed, 11 passed in 69.85s (0:01:09) ====================

They're mostly timeouts, which seems to happen when the player gets stuck with an impossible choice. Example (this repeats forever):

image

To re-run a specific test that failed, you can do this:

pytest -s tests/test_game.py::test_e2e[TEST_NUMBER]

For example: pytest -s tests/test_game.py::test_e2e[4] re-runs test number 4, so you can see the output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants