-
Notifications
You must be signed in to change notification settings - Fork 801
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
Support decoration of async functions #767
base: master
Are you sure you want to change the base?
Conversation
81f873a
to
5d79d22
Compare
Signed-off-by: Yury Pliner <[email protected]>
from concurrent.futures import ThreadPoolExecutor | ||
import time | ||
import unittest | ||
|
||
import pytest | ||
import aiounittest # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No typestub is available
|
||
self.assertEqual(([], None, None, None), getargspec(f)) | ||
|
||
f() | ||
self.assertNotEqual(0, self.registry.get_sample_value('g')) | ||
self.assertTrue(0.05 <= self.registry.get_sample_value('g') <= 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to check the expected duration. It makes more sense in a case of async functions to be sure that the decorator works fine.
|
||
self.assertEqual(([], None, None, None), getargspec(f)) | ||
|
||
f() | ||
self.assertEqual(1, self.registry.get_sample_value('s_count')) | ||
self.assertTrue(.05 < self.registry.get_sample_value('s_sum') < 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
self.assertEqual(([], None, None, None), getargspec(f)) | ||
|
||
f() | ||
self.assertEqual(1, self.registry.get_sample_value('h_count')) | ||
self.assertEqual(1, self.registry.get_sample_value('h_bucket', {'le': '+Inf'})) | ||
self.assertTrue(.05 < self.registry.get_sample_value('h_sum') < 0.1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -6,6 +6,7 @@ envlist = coverage-clean,py3.6,py3.7,py3.8,py3.9,py3.10,pypy3.7,py3.9-nooptional | |||
deps = | |||
coverage | |||
pytest | |||
aiounittest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unittest.IsolatedAsyncioTestCase
is available for python 3.8+, so this module is needed to support async version of unittest.TestCase
.
Only tests to check expected behaviour were added. I hope to finalise the PR after a merge of #766. |
Can I help move this forward in any way? I've implemented the code to handle async and pushed it here: It passes all of your unit tests. |
Hey @Pliner, what's the latest state of this PR? |
Fix #535