test_meta.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:logfury 作者: ppolewicz 项目源码 文件源码
def test_subclass(self):
        @six.add_metaclass(TraceAllPublicCallsMeta)
        class Ala(object):
            def bar(self, a, b, c=None):
                return True

            def __repr__(self):
                return '<%s object>' % (self.__class__.__name__,)

        class Bela(Ala):
            def bar(self, a, b, c=None):
                return False

        with LogCapture() as l:
            a = Ala()
            a.bar(1, 2, 3)
            a.bar(1, b=2)
            l.check(
                (__name__, 'DEBUG', 'calling %sbar(self=<Ala object>, a=1, b=2, c=3)' % (self._get_prefix(),)),
                (__name__, 'DEBUG', 'calling %sbar(self=<Ala object>, a=1, b=2, c=None)' % (self._get_prefix(),)),
            )

        with LogCapture() as l:
            b = Bela()
            b.bar(1, 2, 3)
            b.bar(1, b=2)

            l.check(
                (__name__, 'DEBUG', 'calling %sbar(self=<Bela object>, a=1, b=2, c=3)' % (self._get_prefix(),)),
                (__name__, 'DEBUG', 'calling %sbar(self=<Bela object>, a=1, b=2, c=None)' % (self._get_prefix(),)),
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号