45 lines
978 B
Python
45 lines
978 B
Python
# =====IMPORTS=====
|
|
# Third-party imports
|
|
import pytest
|
|
|
|
# Own imports
|
|
from frank import default, command, daemon
|
|
|
|
|
|
class TestDecorators:
|
|
"""
|
|
This test makes sure the decorated functions return the same result as
|
|
their non-decorated counterparts
|
|
"""
|
|
|
|
def default_no_dec(self):
|
|
return 'default'
|
|
|
|
@default()
|
|
def default_dec(self):
|
|
return self.default_no_dec()
|
|
|
|
def command_no_dec(self):
|
|
return 'command'
|
|
|
|
@command('cmd')
|
|
def command_dec(self):
|
|
return self.command_no_dec()
|
|
|
|
def daemon_no_dec(self):
|
|
return 'daemon'
|
|
|
|
@daemon()
|
|
async def daemon_dec(self):
|
|
return self.daemon_no_dec()
|
|
|
|
def test_default(self):
|
|
assert self.default_no_dec() == self.default_dec()
|
|
|
|
def test_command(self):
|
|
assert self.command_no_dec() == self.command_dec()
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_daemon(self):
|
|
assert self.daemon_no_dec() == await self.daemon_dec()
|