Issue #7051: Clarify behaviour of 'g' and 'G'-style formatting.
[python.git] / Lib / test / test_undocumented_details.py
blobca66c19f65f3af82e8c768aca32d31b7935fc22f
1 from test.test_support import run_unittest, have_unicode
2 import unittest
3 import sys
5 class TestImplementationComparisons(unittest.TestCase):
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)
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)
35 def test_main():
36 run_unittest(TestImplementationComparisons)
38 if __name__ == '__main__':
39 test_main()