Ejemplo n.º 1
0
def test_warn_old_client():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')
        Session(get_client(cls=CustomRedis))
        assert len(w) == 0
    old_client = get_client(cls=Redis)
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')
        Session(old_client)
        assert len(w) == 1
        assert issubclass(w[0].category, DeprecationWarning)
Ejemplo n.º 2
0
def init_session():
    client = get_client()
    try:
        session = Session(client)
        session.verbose_transaction_error = True
        yield session
    finally:
        #: .. note::
        #:
        #:    Using ``FLUSHALL`` command is more easier and faster, but it's
        #:    also harmful because it flushes all data in the selected db.
        #:
        #:    However if it is assumed that there is no meaningful data in the
        #:    db, ``client.flushall()`` can be used safely and the testing
        #:    speed will be improved.
        used_keys = client.keys(prefix + '*')
        if used_keys:
            client.delete(*used_keys)
Ejemplo n.º 3
0
Archivo: env.py Proyecto: pmuston/sider
def get_session(client=None):
    if client is None:
        client = get_client()
    session = Session(client)
    session.verbose_transaction_error = True
    return session
Ejemplo n.º 4
0
def get_session(client=None):
    if client is None:
        client = get_client()
    session = Session(client)
    session.verbose_transaction_error = True
    return session
Ejemplo n.º 5
0
def get_session():
    session = Session(get_client())
    session.verbose_transaction_error = True
    return session