Support decoration of async functions #767
Conversation
81f873a to
5d79d22
Compare
Signed-off-by: Yury Pliner <yury.pliner@gmail.com>
| import unittest | ||
|
|
||
| import pytest | ||
| import aiounittest # type: ignore |
There was a problem hiding this comment.
No typestub is available
|
|
||
| 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.
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.
|
|
||
| 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.
| 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.
| deps = | ||
| coverage | ||
| pytest | ||
| aiounittest |
There was a problem hiding this comment.
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