def test_enable_log_called_twice(self): storops.enable_log() storops.enable_log(logging.INFO) log = logging.getLogger('storops') assert_that(len(log.handlers), equal_to(1)) assert_that(log.handlers[0], instance_of(logging.StreamHandler)) assert_that(log.getEffectiveLevel(), equal_to(logging.INFO))
from __future__ import division import itertools import math import sys from contextlib import contextmanager from functools import wraps from multiprocessing import dummy as multithread from time import time import storops storops.enable_log() def timing(f): @wraps(f) def wrap(*args, **kwargs): ts = time() result = f(*args, **kwargs) te = time() print('func:{} args:[{}, {}], time: {:.4f},{:.4f},{:.4f}'.format( f.__name__, [to_str(each) for each in args], kwargs, ts, te, te - ts)) return result return wrap def to_str(obj): if (isinstance(obj, storops.unity.resource.host.UnityHost)
def setUpClass(cls): storops.enable_log()
def test_disable_log(self): storops.enable_log() log = storops.disable_log() assert_that(len(log.handlers), equal_to(0))