move sections
[python/dscho.git] / Lib / test / test_undocumented_details.py
bloba8fc280c67a1edb5381c84ce2bf95b27a2d421a5
1 from test.test_support import run_unittest, check_py3k_warnings
2 import unittest
4 class TestImplementationComparisons(unittest.TestCase):
6 def test_type_comparisons(self):
7 self.assertTrue(str < int or str > int)
8 self.assertTrue(int <= str or int >= str)
9 self.assertTrue(cmp(int, str) != 0)
10 self.assertTrue(int is int)
11 self.assertTrue(str == str)
12 self.assertTrue(int != str)
14 def test_cell_comparisons(self):
15 def f(x):
16 if x:
17 y = 1
18 def g():
19 return x
20 def h():
21 return y
22 return g, h
23 g, h = f(0)
24 g_cell, = g.func_closure
25 h_cell, = h.func_closure
26 self.assertTrue(h_cell < g_cell)
27 self.assertTrue(g_cell >= h_cell)
28 self.assertEqual(cmp(g_cell, h_cell), 1)
29 self.assertTrue(g_cell is g_cell)
30 self.assertTrue(g_cell == g_cell)
31 self.assertTrue(h_cell == h_cell)
32 self.assertTrue(g_cell != h_cell)
34 def test_main():
35 with check_py3k_warnings():
36 run_unittest(TestImplementationComparisons)
38 if __name__ == '__main__':
39 test_main()