def test_deepcopy(self): """ __getattr__ returns None for '__deepcopy__' """ b = BoundLogger( ReturnLogger(), _CONFIG.default_processors, _CONFIG.default_context_class(), ) assert b.__deepcopy__ is None
def test_proxies_anything(self): """ Anything that isn't part of BoundLoggerBase gets proxied to the correct wrapped logger methods. """ b = BoundLogger( ReturnLogger(), _CONFIG.default_processors, _CONFIG.default_context_class(), ) assert 'log', 'foo' == b.log('foo') assert 'gol', 'bar' == b.gol('bar')
def test_caches(self): """ __getattr__() gets called only once per logger method. """ b = BoundLogger( ReturnLogger(), _CONFIG.default_processors, _CONFIG.default_context_class(), ) assert 'msg' not in b.__dict__ b.msg('foo') assert 'msg' in b.__dict__
def test_proxies_anything(self): """ Anything that isn't part of BoundLoggerBase gets proxied to the correct wrapped logger methods. """ b = BoundLogger( ReturnLogger(), _CONFIG.default_processors, _CONFIG.default_context_class(), ) assert "log", "foo" == b.log("foo") assert "gol", "bar" == b.gol("bar")
def test_pickle(self, proto): """ Can be pickled and unpickled. Works only on Python 3: TypeError: can't pickle instancemethod objects """ b = BoundLogger( ReturnLogger(), _CONFIG.default_processors, _CONFIG.default_context_class(), ).bind(x=1) assert b.info("hi") == pickle.loads(pickle.dumps(b, proto)).info("hi")