Skip to content

Commit

Permalink
A handy property for applicable test case class: _session
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jul 18, 2019
1 parent 90072f6 commit d477a26
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions restfulpy/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ class ApplicableTestCase:
_sessions = []
_authentication_token = None
__metadata__ = None
__session = None

@classmethod
def configure_application(cls):
Expand All @@ -164,6 +165,13 @@ def create_session(cls, *a, expire_on_commit=False, **kw):
cls._sessions.append(new_session)
return new_session

@property
def _session(self):
if self.__session is None:
self.__session == self.create_session()

return self.__session

@classmethod
def initialize_orm(cls):
# Drop the previosely created db if exists.
Expand Down

0 comments on commit d477a26

Please sign in to comment.