@fixture
def db():
 global _db
 if (_db is None):
  _db = orm.new_session_factory('sqlite:///:memory:', echo=True)()
  user = orm.User(name=getuser())
  user.servers.append(orm.Server())
  hub = orm.Hub(server=orm.Server())
  _db.add(user)
  _db.add(hub)
  _db.commit()
 return _db

@ fixture def db ( ) : global _db if ( _db is None ) : _db = orm . new_session_factory ( 'sqlite:///:memory:' , echo = True ) ( ) user = orm . User ( name = getuser ( ) ) user . servers . append ( orm . Server ( ) ) hub = orm . Hub ( server = orm . Server ( ) ) _db . add ( user ) _db . add ( hub ) _db . commit ( ) return _db
get a db session .