コード例 #1
0
ファイル: viewderivers.py プロジェクト: zpyang2920/pyramid
    def __call__(self, view):
        if is_unbound_method(view) and self.attr is None:
            raise ConfigurationError((
                'Unbound method calls are not supported, please set the class '
                'as your `view` and the method as your `attr`'))

        if inspect.isclass(view):
            view = self.map_class(view)
        else:
            view = self.map_nonclass(view)
        return view
コード例 #2
0
ファイル: viewderivers.py プロジェクト: arianmaykon/pyramid
    def __call__(self, view):
        if is_unbound_method(view) and self.attr is None:
            raise ConfigurationError((
                'Unbound method calls are not supported, please set the class '
                'as your `view` and the method as your `attr`'
            ))

        if inspect.isclass(view):
            view = self.map_class(view)
        else:
            view = self.map_nonclass(view)
        return view
コード例 #3
0
 def test_new_style_bound(self):
     self.assertFalse(is_unbound_method(NewStyle().run))
コード例 #4
0
    def test_normal_func_unbound(self):
        def func():  # pragma: no cover
            return 'OK'

        self.assertFalse(is_unbound_method(func))
コード例 #5
0
 def test_old_style_bound(self):
     self.assertFalse(is_unbound_method(OldStyle().run))
コード例 #6
0
 def test_old_style_unbound(self):
     self.assertTrue(is_unbound_method(OldStyle.run))
コード例 #7
0
 def test_new_style_unbound(self):
     self.assertTrue(is_unbound_method(NewStyle.run))
コード例 #8
0
ファイル: test_compat.py プロジェクト: 7924102/pyramid
 def test_new_style_bound(self):
     self.assertFalse(is_unbound_method(NewStyle().run))
コード例 #9
0
ファイル: test_compat.py プロジェクト: 7924102/pyramid
 def test_old_style_bound(self):
     self.assertFalse(is_unbound_method(OldStyle().run))
コード例 #10
0
ファイル: test_compat.py プロジェクト: 7924102/pyramid
    def test_normal_func_unbound(self):
        def func(): return 'OK'

        self.assertFalse(is_unbound_method(func))
コード例 #11
0
ファイル: test_compat.py プロジェクト: 7924102/pyramid
 def test_new_style_unbound(self):
     self.assertTrue(is_unbound_method(NewStyle.run))
コード例 #12
0
ファイル: test_compat.py プロジェクト: 7924102/pyramid
 def test_old_style_unbound(self):
     self.assertTrue(is_unbound_method(OldStyle.run))