File: test_compat.py

package info (click to toggle)
python-pyramid 1.6+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,112 kB
  • ctags: 8,169
  • sloc: python: 41,764; makefile: 111; sh: 17
file content (26 lines) | stat: -rw-r--r-- 720 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import unittest
from pyramid.compat import is_unbound_method

class TestUnboundMethods(unittest.TestCase):
    def test_old_style_bound(self):
        self.assertFalse(is_unbound_method(OldStyle().run))

    def test_new_style_bound(self):
        self.assertFalse(is_unbound_method(NewStyle().run))

    def test_old_style_unbound(self):
        self.assertTrue(is_unbound_method(OldStyle.run))

    def test_new_style_unbound(self):
        self.assertTrue(is_unbound_method(NewStyle.run))

    def test_normal_func_unbound(self):
        def func(): return 'OK'

        self.assertFalse(is_unbound_method(func))

class OldStyle:
    def run(self): return 'OK'

class NewStyle(object):
    def run(self): return 'OK'