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

Let unittest frameworks deal with async functions #7144

Merged
merged 1 commit into from May 1, 2020

Conversation

nicoddemus
Copy link
Member

@nicoddemus nicoddemus commented May 1, 2020

Instead of trying to handle unittest-async functions in pytest_pyfunc_call,
let the unittest framework handle them instead.

This lets us remove the hack in pytest_pyfunc_call, with the upside that
we should support any unittest-async based framework.

Also included asynctest as test dependency for py37-twisted, and renamed
twisted to unittestextras to better reflect that we install twisted and
asynctest now instead of only twisted.

This also fixes the problem of cleanUp functions not being properly called for async functions.

Fix #7110
Fix #6924

@nicoddemus nicoddemus added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label May 1, 2020
Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we perhaps should remove wrappers alltogether, are there exception handling hooks in the reporting for pdb to be hooked in

@nicoddemus
Copy link
Member Author

I wonder if we perhaps should remove wrappers alltogether, are there exception handling hooks in the reporting for pdb to be hooked in

Definitely, but I prefer to do that in a separate PR (which I intend to tackle next).

Btw noticed that this also fixes #6924 regarding clean up functions not being called, so I updated both tests to also ensure that.

Copy link
Member

@RonnyPfannschmidt RonnyPfannschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely then, im curious about the followup as well

Instead of trying to handle unittest-async functions in pytest_pyfunc_call,
let the unittest framework handle them instead.

This lets us remove the hack in pytest_pyfunc_call, with the upside that
we should support any unittest-async based framework.

Also included 'asynctest' as test dependency for py37-twisted, and renamed
'twisted' to 'unittestextras' to better reflect that we install 'twisted' and
'asynctest' now.

This also fixes the problem of cleanUp functions not being properly called
for async functions.

Fix pytest-dev#7110
Fix pytest-dev#6924
@nicoddemus nicoddemus merged commit e364375 into pytest-dev:master May 1, 2020
@nicoddemus nicoddemus deleted the async-testcase-7110 branch May 1, 2020 19:44
nicoddemus added a commit to nicoddemus/pytest that referenced this pull request May 1, 2020
@nicoddemus nicoddemus added backported PR has been backported to the current bug-fix branch and removed needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch labels May 1, 2020
Copy link

@kasunsewwandika kasunsewwandika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-]()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported PR has been backported to the current bug-fix branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pytest now skips async tests pytest 5.4+ doesn't handle IsolatedAsyncioTestCase from CPython core.
3 participants