コード例 #1
0
ファイル: test_meta.py プロジェクト: Atch0um/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)
コード例 #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
ファイル: test_meta.py プロジェクト: Atch0um/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)