示例#1
0
 def test_it_does_not_attach_method_if_attribute_exists(self):
     class cls:
         def method(self):
             pass
     method = mock.Mock(__name__='method')
     with self.assertRaises(AttributeError):
         meta.add_method(cls)(method)
示例#2
0
文件: test_meta.py 项目: vhb/pyrser
    def test_it_attach_method_to_class(self):
        class cls:
            pass

        method = mock.Mock(__name__='method', __doc__='doc string')
        meta.add_method(cls)(method)
        self.assertIs(method, cls.method)
示例#3
0
文件: test_meta.py 项目: vhb/pyrser
    def test_it_does_not_attach_method_if_attribute_exists(self):
        class cls:
            def method(self):
                pass

        method = mock.Mock(__name__='method')
        with self.assertRaises(AttributeError):
            meta.add_method(cls)(method)
示例#4
0
 def test_it_attach_method_to_class(self):
     class cls:
         pass
     method = mock.Mock(__name__='method', __doc__='doc string')
     meta.add_method(cls)(method)
     self.assertIs(method, cls.method)