Skip to content

Commit aef24fa

Browse files
oleksandr-kuzmenkoasvetlov
authored andcommitted
aiohttp-session is not required (#107)
* aiohttp_session is not required * fix code coverage * has_aiohttp_session -> HAS_AIOHTTP_SESSION
1 parent 747ec05 commit aef24fa

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

aiohttp_security/session_identity.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
import asyncio
88

9-
from aiohttp_session import get_session
9+
try:
10+
from aiohttp_session import get_session
11+
HAS_AIOHTTP_SESSION = True
12+
except ImportError: # pragma: no cover
13+
HAS_AIOHTTP_SESSION = False
1014

1115
from .abc import AbstractIdentityPolicy
1216

@@ -16,6 +20,10 @@ class SessionIdentityPolicy(AbstractIdentityPolicy):
1620
def __init__(self, session_key='AIOHTTP_SECURITY'):
1721
self._session_key = session_key
1822

23+
if not HAS_AIOHTTP_SESSION: # pragma: no cover
24+
raise ImportError(
25+
'SessionIdentityPolicy requires `aiohttp_session`')
26+
1927
@asyncio.coroutine
2028
def identify(self, request):
2129
session = yield from get_session(request)

0 commit comments

Comments
 (0)