FAForever / server

The servercode for the Forged Alliance Forever lobby
http://www.faforever.com
GNU General Public License v3.0
66 stars 61 forks source link

RuntimeError raised when running some tests on their own #894

Open Askaholic opened 2 years ago

Askaholic commented 2 years ago

There are some tests that construct objects which try to access the current event loop in their constructors (such as Search and Game). If these tests are not declared to be async then when they are run in isolation they will raise this error:

RuntimeError: There is no current event loop in thread 'MainThread'.

However, they work when running the test suite as a whole because they will get the event loop created by previous tests. Either the tests should be converted to async functions, or the classes causing the problem need to be refactored so that they can be constructed without an event loop existing.

Currently at least these tests have the problem:

The error can be reproduced by running tests like this pipenv run tests tests/unit_tests/test_matchmaker_algorithm_bucket_teams.py::test_make_teams_single_correct_size