def test_use_master(): local = context.multidb.pinning._locals eq_(getattr(local, 'pinned', False), False) with context.use_master(): eq_(local.pinned, True) with context.use_master(): eq_(local.pinned, True) eq_(local.pinned, True) eq_(local.pinned, False)
def test_use_master(): multidb.pinning.unpin_this_thread() local = models.multidb.pinning._locals eq_(getattr(local, 'pinned', False), False) with models.use_master(): eq_(local.pinned, True) with models.use_master(): eq_(local.pinned, True) eq_(local.pinned, True) eq_(local.pinned, False)
def wrapper(*args, **kw): with models.use_master(): return f(*args, **kw)