|
1 | 1 | import mock
|
2 | 2 | import pytest
|
3 | 3 | from fqn_decorators import get_fqn
|
4 |
| -from fqn_decorators.async import AsyncDecorator |
5 |
| - |
6 |
| -# All test functions in this module will be treated as coroutines. |
7 |
| -# This avoids having to decorate every function with ``@pytest.mark.asyncio``. |
8 |
| -pytestmark = pytest.mark.asyncio |
| 4 | +from fqn_decorators.asynchronous import AsyncDecorator |
9 | 5 |
|
10 | 6 |
|
11 | 7 | class TestFqnAsync:
|
12 |
| - async def test_class_async(self): |
| 8 | + def test_class_async(self): |
13 | 9 | assert get_fqn(AsyncDecorator) == \
|
14 |
| - 'fqn_decorators.async.AsyncDecorator' |
| 10 | + 'fqn_decorators.asynchronous.AsyncDecorator' |
15 | 11 |
|
16 |
| - async def test_method_async(self): |
| 12 | + def test_method_async(self): |
17 | 13 | assert get_fqn(AsyncDecorator().before) == \
|
18 |
| - 'fqn_decorators.async.AsyncDecorator.before' |
| 14 | + 'fqn_decorators.asynchronous.AsyncDecorator.before' |
19 | 15 |
|
20 |
| - async def test_decorated_method_async(self): |
| 16 | + def test_decorated_method_async(self): |
21 | 17 | assert get_fqn(AsyncDecorator().before) == \
|
22 |
| - 'fqn_decorators.async.AsyncDecorator.before' |
| 18 | + 'fqn_decorators.asynchronous.AsyncDecorator.before' |
23 | 19 |
|
24 |
| - async def test_decorated_method(self): |
| 20 | + def test_decorated_method(self): |
25 | 21 | class User:
|
26 | 22 | @AsyncDecorator
|
27 | 23 | async def method(self, a):
|
28 | 24 | return a
|
29 | 25 |
|
30 | 26 | assert get_fqn(User().method) == \
|
31 |
| - 'tests.test_fqn_decorators_async.User.method' |
| 27 | + 'tests.test_fqn_decorators_asynchronous.User.method' |
32 | 28 |
|
33 | 29 |
|
| 30 | +@pytest.mark.asyncio |
34 | 31 | class TestAsyncDecorator:
|
35 | 32 | async def test_getattr_async(self):
|
36 | 33 | class Decorator(AsyncDecorator):
|
@@ -105,7 +102,7 @@ class User:
|
105 | 102 | def check_permission(self):
|
106 | 103 | raise RuntimeError('Permission denied')
|
107 | 104 |
|
108 |
| - with mock.patch('fqn_decorators.async.AsyncDecorator.exception') as mocked_method: |
| 105 | + with mock.patch('fqn_decorators.asynchronous.AsyncDecorator.exception') as mocked_method: |
109 | 106 | with pytest.raises(RuntimeError):
|
110 | 107 | await User().check_permission()
|
111 | 108 | assert mocked_method.called is True
|
|
0 commit comments