Skip to content

Conversation

johnzhou721
Copy link
Contributor

No description provided.

@johnzhou721
Copy link
Contributor Author

@hosaka Please approve CI for this... thanks! Passing on my mac but not sure if on other platforms.

@johnzhou721
Copy link
Contributor Author

@TheGreatCabbage since you're in this org wondering if you could approve me to run the workflows.

@hosaka -- sorry, meant rerun not approve in the last comment.

@hosaka
Copy link
Collaborator

hosaka commented Jul 23, 2025

Your last assert is effectively never executed in a test run, you're just ignoring the the RuntimeError being raised by the get_event_loop. A more concise approach would be to explicitly set the event loop to None before running qasync.run(), and check for the RuntimeError, so the test run works standalone and when running all tests.

import asyncio
import os

import pytest

import qasync


def test_run_with_contextmanager(application):
    async def coro():
        event_loop = asyncio.get_event_loop()
        assert (
            type(event_loop).__name__ == "QIOCPEventLoop"
            if os.name == "nt"
            else "QSelectorEventLoop"
        )
        await asyncio.sleep(0)

    asyncio.set_event_loop(None)
    qasync.run(coro())

    with pytest.raises(RuntimeError):
        _ = asyncio.get_event_loop()

@hosaka hosaka self-assigned this Jul 23, 2025
@hosaka
Copy link
Collaborator

hosaka commented Jul 24, 2025

@johnzhou721 Thanks for the fixes! I took the liberty to tidy up the changes. I am going to move the *.run tests into test_run.py from #138 as well. Looks like something is broken on windows with one of the tests: https://github.com/CabbageDevelopment/qasync/actions/runs/16486604870/job/46612434018?pr=134

macos tests are flaky because of a subprocess timeout I think...

@johnzhou721
Copy link
Contributor Author

@hosaka I don't kow, I don't have a Windows machine. Are you suggesting the macOS tests are failing becasue of this or not? Also is it true that you can't catch the access violation because you're somehow accessing None in asyncio or something... an error is expected there, we just had to catch it... not sure what I can do about this.

Since the macOS stuff is failing because of probably unrelated versions, can I please get a rerun before I dig into the Windwos stuff?

@hosaka
Copy link
Collaborator

hosaka commented Jul 24, 2025

MacOs tests failure are unreleated and should be fixed elsewhere, by the looks of it, the failing windows test is also a different quirk. Let me know if you're happy with my changes and i'll merge this.

@johnzhou721
Copy link
Contributor Author

LGTM! Let us merge.

Guess we got really unlucky... 3 stuff failing at the same time.

@hosaka hosaka merged commit de293ac into CabbageDevelopment:master Jul 24, 2025
143 of 146 checks passed
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