PageRenderTime 61ms CodeModel.GetById 31ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 0ms

/Lib/test/test_undocumented_details.py

http://unladen-swallow.googlecode.com/
Python | 39 lines | 34 code | 5 blank | 0 comment | 4 complexity | 2172acccfc69834d45985814d2ed8749 MD5 | raw file
 1from test.test_support import run_unittest, have_unicode
 2import unittest
 3import sys
 4
 5class TestImplementationComparisons(unittest.TestCase):
 6
 7    def test_type_comparisons(self):
 8        self.assertTrue(str < int or str > int)
 9        self.assertTrue(int <= str or int >= str)
10        self.assertTrue(cmp(int, str) != 0)
11        self.assertTrue(int is int)
12        self.assertTrue(str == str)
13        self.assertTrue(int != str)
14
15    def test_cell_comparisons(self):
16        def f(x):
17            if x:
18                y = 1
19            def g():
20                return x
21            def h():
22                return y
23            return g, h
24        g, h = f(0)
25        g_cell, = g.func_closure
26        h_cell, = h.func_closure
27        self.assertTrue(h_cell < g_cell)
28        self.assertTrue(g_cell >= h_cell)
29        self.assertEqual(cmp(g_cell, h_cell), 1)
30        self.assertTrue(g_cell is g_cell)
31        self.assertTrue(g_cell == g_cell)
32        self.assertTrue(h_cell == h_cell)
33        self.assertTrue(g_cell != h_cell)
34
35def test_main():
36    run_unittest(TestImplementationComparisons)
37
38if __name__ == '__main__':
39    test_main()