datasette: Test failures in CI: There is no current event loop in thread 'MainThread'

Oddly they don’t affect all versions of Python: https://github.com/simonw/datasette/actions/runs/13096055517/job/36538457787

Image

=========================== short test summary info ============================
FAILED tests/test_permissions.py::test_cli_create_token[options0-expected0] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
FAILED tests/test_permissions.py::test_cli_create_token[options1-expected1] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
FAILED tests/test_permissions.py::test_cli_create_token[options2-expected2] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
FAILED tests/test_permissions.py::test_cli_create_token[options3-expected3] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
FAILED tests/test_permissions.py::test_cli_create_token[options4-expected4] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
FAILED tests/test_permissions.py::test_cli_create_token[options5-expected5] - AssertionError: 
assert 0 == 1
 +  where 1 = <Result RuntimeError("There is no current event loop in thread 'MainThread'.")>.exit_code
= 6 failed, 1447 passed, 7 skipped, 1 xfailed, 2 xpassed in 172.41s (0:02:52) ==

Looks like they affect the tests of various CLI tools.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Incredibly useful command I just figured out for running the tests under a specific Python version:

uv run --python 3.12 \
  --with pytest-cov \
  --with '.[test]' pytest \
    -Werror \
    -m "not serial" \
    --cov=datasette \
    --cov-config=.coveragerc \
    --cov-report xml:coverage.xml \
    --cov-report term \
    -x -k test_cli_create_token