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

Functional tests failing due to setup function skip. #122

Closed
dashmage opened this issue Dec 4, 2023 · 3 comments
Closed

Functional tests failing due to setup function skip. #122

dashmage opened this issue Dec 4, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@dashmage
Copy link
Contributor

dashmage commented Dec 4, 2023

Running make functional31 skips the test_build_and_deploy setup function and causes the rest of the tests to fail. Here's the relevant bits from the error log

tests/functional/test_charm.py::test_build_and_deploy
  tests/functional/test_charm.py:43: PytestWarning: The test <Function test_build_and_deploy> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove the asyncio mark. If the test is not marked explicitly, check for global marks applied via 'pytestmark'.
    @pytest.mark.abort_on_fail

tests/functional/test_charm.py::test_build_and_deploy
  /home/dashmage/Canonical/repo/hardware-observer-operator/.tox/func31/lib/python3.11/site-packages/_pytest/python.py:183: PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped.
  You need to install a suitable plugin for your async framework, for example:
    - anyio
    - pytest-asyncio
    - pytest-tornasync
    - pytest-trio
    - pytest-twisted
    warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid)))

Error can be seen in this failed CI run. On GitHub, the test is passing for make functional31 which isn't the case on my local.

@dashmage
Copy link
Contributor Author

dashmage commented Dec 4, 2023

Working with changes in this commit.

Possible source of error:
pytest-asyncio has some breaking changes in v0.23.0 released on 12/03 and is used by pytest-operator internally.

This issue where it's also causing some unneccessary skips, has been fixed in v0.23.1. But even after using this latest version, I'm not able to get the func tests to work without adding pytestmark = pytest.mark.asyncio(scope="module") in the test.

@dashmage dashmage added the bug Something isn't working label Dec 4, 2023
@jneo8
Copy link
Contributor

jneo8 commented Dec 5, 2023

charmed-kubernetes/pytest-operator#120

Fix is there. We should be fine now.

@dashmage
Copy link
Contributor Author

dashmage commented Dec 5, 2023

Can verify the fix is good in this PR from this job run. Closing the issue.

@dashmage dashmage closed this as completed Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants