annotate Lib/test/test_types.py @ 79691:05c8928362ee

Merge __next__ method link fixes with 3.3.
author Ezio Melotti <ezio.melotti@gmail.com>
date Fri, 12 Oct 2012 13:46:37 +0300
parents e99c0425da59
children c5124145e79e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Python test set -- part 6, built-in types
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 46909
diff changeset
3 from test.support import run_unittest, run_with_locale
76334
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
4 import collections
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
5 import locale
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
6 import sys
76334
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
7 import types
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
8 import unittest
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
9
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
10 class TypesTests(unittest.TestCase):
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
11
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
12 def test_truth_values(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
13 if None: self.fail('None is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
14 if 0: self.fail('0 is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
15 if 0.0: self.fail('0.0 is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
16 if '': self.fail('\'\' is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
17 if not 1: self.fail('1 is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
18 if not 1.0: self.fail('1.0 is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
19 if not 'x': self.fail('\'x\' is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
20 if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
21 def f(): pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
22 class C: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
23 x = C()
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
24 if not f: self.fail('f is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
25 if not C: self.fail('C is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
26 if not sys: self.fail('sys is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
27 if not x: self.fail('x is false instead of true')
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
29 def test_boolean_ops(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
30 if 0 or 0: self.fail('0 or 0 is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
31 if 1 and 1: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
32 else: self.fail('1 and 1 is false instead of true')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
33 if not 1: self.fail('not 1 is true instead of false')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
34
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
35 def test_comparisons(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
36 if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
37 else: self.fail('int comparisons failed')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
38 if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
39 else: self.fail('float comparisons failed')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
40 if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
41 else: self.fail('string comparisons failed')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
42 if None is None: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
43 else: self.fail('identity test failed')
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
45 def test_float_constructor(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
46 self.assertRaises(ValueError, float, '')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
47 self.assertRaises(ValueError, float, '5\0')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
48
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
49 def test_zero_division(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
50 try: 5.0 / 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
51 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
52 else: self.fail("5.0 / 0.0 didn't raise ZeroDivisionError")
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
53
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
54 try: 5.0 // 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
55 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
56 else: self.fail("5.0 // 0.0 didn't raise ZeroDivisionError")
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
57
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
58 try: 5.0 % 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
59 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
60 else: self.fail("5.0 % 0.0 didn't raise ZeroDivisionError")
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
61
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
62 try: 5 / 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
63 except ZeroDivisionError: pass
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
64 else: self.fail("5 / 0 didn't raise ZeroDivisionError")
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
65
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
66 try: 5 // 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
67 except ZeroDivisionError: pass
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
68 else: self.fail("5 // 0 didn't raise ZeroDivisionError")
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
69
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
70 try: 5 % 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
71 except ZeroDivisionError: pass
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
72 else: self.fail("5 % 0 didn't raise ZeroDivisionError")
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
73
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
74 def test_numeric_types(self):
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
75 if 0 != 0.0 or 1 != 1.0 or -1 != -1.0:
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
76 self.fail('int/float value not equal')
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
77 # calling built-in types without argument must return 0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
78 if int() != 0: self.fail('int() does not return 0')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
79 if float() != 0.0: self.fail('float() does not return 0.0')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
80 if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
81 else: self.fail('int() does not round properly')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
82 if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
83 else: self.fail('float() does not work properly')
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
84
45435
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
85 def test_float_to_string(self):
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
86 def test(f, result):
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
87 self.assertEqual(f.__format__('e'), result)
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
88 self.assertEqual('%e' % f, result)
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
89
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
90 # test all 2 digit exponents, both with __format__ and with
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
91 # '%' formatting
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
92 for i in range(-99, 100):
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
93 test(float('1.5e'+str(i)), '1.500000e{0:+03d}'.format(i))
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
94
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
95 # test some 3 digit exponents
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
96 self.assertEqual(1.5e100.__format__('e'), '1.500000e+100')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
97 self.assertEqual('%e' % 1.5e100, '1.500000e+100')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
98
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
99 self.assertEqual(1.5e101.__format__('e'), '1.500000e+101')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
100 self.assertEqual('%e' % 1.5e101, '1.500000e+101')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
101
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
102 self.assertEqual(1.5e-100.__format__('e'), '1.500000e-100')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
103 self.assertEqual('%e' % 1.5e-100, '1.500000e-100')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
104
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
105 self.assertEqual(1.5e-101.__format__('e'), '1.500000e-101')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
106 self.assertEqual('%e' % 1.5e-101, '1.500000e-101')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
107
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
108 self.assertEqual('%g' % 1.0, '1')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
109 self.assertEqual('%#g' % 1.0, '1.00000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
110
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
111 def test_normal_integers(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
112 # Ensure the first 256 integers are shared
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
113 a = 256
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
114 b = 128*2
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
115 if a is not b: self.fail('256 is not shared')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
116 if 12 + 24 != 36: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
117 if 12 + (-24) != -12: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
118 if (-12) + 24 != 12: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
119 if (-12) + (-24) != -36: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
120 if not 12 < 24: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
121 if not -24 < -12: self.fail('int op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
122 # Test for a particular bug in integer multiply
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
123 xsize, ysize, zsize = 238, 356, 4
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
124 if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
125 self.fail('int mul commutativity')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
126 # And another.
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
127 m = -sys.maxsize - 1
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
128 for divisor in 1, 2, 4, 8, 16, 32:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
129 j = m // divisor
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
130 prod = divisor * j
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
131 if prod != m:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
132 self.fail("%r * %r == %r != %r" % (divisor, j, prod, m))
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
133 if type(prod) is not int:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
134 self.fail("expected type(prod) to be int, not %r" %
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
135 type(prod))
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
136 # Check for unified integral type
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
137 for divisor in 1, 2, 4, 8, 16, 32:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
138 j = m // divisor - 1
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
139 prod = divisor * j
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
140 if type(prod) is not int:
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
141 self.fail("expected type(%r) to be int, not %r" %
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
142 (prod, type(prod)))
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
143 # Check for unified integral type
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
144 m = sys.maxsize
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
145 for divisor in 1, 2, 4, 8, 16, 32:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
146 j = m // divisor + 1
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
147 prod = divisor * j
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
148 if type(prod) is not int:
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
149 self.fail("expected type(%r) to be int, not %r" %
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
150 (prod, type(prod)))
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
151
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
152 x = sys.maxsize
58473
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
153 self.assertIsInstance(x + 1, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
154 "(sys.maxsize + 1) should have returned int")
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
155 self.assertIsInstance(-x - 1, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
156 "(-sys.maxsize - 1) should have returned int")
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
157 self.assertIsInstance(-x - 2, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
158 "(-sys.maxsize - 2) should have returned int")
21206
81928c9d7011 SF bug #488480: integer multiply to return -max_int-1.
Tim Peters <tim.peters@gmail.com>
parents: 18284
diff changeset
159
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
160 try: 5 << -5
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
161 except ValueError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
162 else: self.fail('int negative shift <<')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
163
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
164 try: 5 >> -5
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
165 except ValueError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
166 else: self.fail('int negative shift >>')
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
167
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
168 def test_floats(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
169 if 12.0 + 24.0 != 36.0: self.fail('float op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
170 if 12.0 + (-24.0) != -12.0: self.fail('float op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
171 if (-12.0) + 24.0 != 12.0: self.fail('float op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
172 if (-12.0) + (-24.0) != -36.0: self.fail('float op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
173 if not 12.0 < 24.0: self.fail('float op')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
174 if not -24.0 < -12.0: self.fail('float op')
22489
6039254aaadc Add more tests for built-in types. Add tests for buffer objects.
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 21497
diff changeset
175
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
176 def test_strings(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
177 if len('') != 0: self.fail('len(\'\')')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
178 if len('a') != 1: self.fail('len(\'a\')')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
179 if len('abcdef') != 6: self.fail('len(\'abcdef\')')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
180 if 'xyz' + 'abcde' != 'xyzabcde': self.fail('string concatenation')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
181 if 'xyz'*3 != 'xyzxyzxyz': self.fail('string repetition *3')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
182 if 0*'abcde' != '': self.fail('string repetition 0*')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
183 if min('abc') != 'a' or max('abc') != 'c': self.fail('min/max string')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
184 if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
185 else: self.fail('in/not in string')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
186 x = 'x'*103
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
187 if '%s!'%x != x+'!': self.fail('nasty string formatting bug')
1097
c644bc626098 Added some new tests and two new files for testing: test_types.py
Guido van Rossum <guido@python.org>
parents:
diff changeset
188
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
189 #extended slices for strings
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
190 a = '0123456789'
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
191 self.assertEqual(a[::], a)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
192 self.assertEqual(a[::2], '02468')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
193 self.assertEqual(a[1::2], '13579')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
194 self.assertEqual(a[::-1],'9876543210')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
195 self.assertEqual(a[::-2], '97531')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
196 self.assertEqual(a[3::-2], '31')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
197 self.assertEqual(a[-100:100:], a)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
198 self.assertEqual(a[100:-100:-1], a[::-1])
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
199 self.assertEqual(a[-100:100:2], '02468')
23778
245224d1b8c9 This is my nearly two year old patch
Michael W. Hudson <mwh@python.net>
parents: 23335
diff changeset
200
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
201 def test_type_function(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
202 self.assertRaises(TypeError, type, 1, 2)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
203 self.assertRaises(TypeError, type, 1, 2, 3, 4)
21341
0b1faf116f63 Additional coverage tests by Neil Norwitz.
Guido van Rossum <guido@python.org>
parents: 21207
diff changeset
204
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
205 def test_int__format__(self):
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
206 def test(i, format_spec, result):
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
207 # just make sure we have the unified type for integers
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
208 assert type(i) == int
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
209 assert type(format_spec) == str
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
210 self.assertEqual(i.__format__(format_spec), result)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
211
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
212 test(123456789, 'd', '123456789')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
213 test(123456789, 'd', '123456789')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
214
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
215 test(1, 'c', '\01')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
216
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
217 # sign and aligning are interdependent
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
218 test(1, "-", '1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
219 test(-1, "-", '-1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
220 test(1, "-3", ' 1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
221 test(-1, "-3", ' -1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
222 test(1, "+3", ' +1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
223 test(-1, "+3", ' -1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
224 test(1, " 3", ' 1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
225 test(-1, " 3", ' -1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
226 test(1, " ", ' 1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
227 test(-1, " ", '-1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
228
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
229 # hex
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
230 test(3, "x", "3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
231 test(3, "X", "3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
232 test(1234, "x", "4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
233 test(-1234, "x", "-4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
234 test(1234, "8x", " 4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
235 test(-1234, "8x", " -4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
236 test(1234, "x", "4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
237 test(-1234, "x", "-4d2")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
238 test(-3, "x", "-3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
239 test(-3, "X", "-3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
240 test(int('be', 16), "x", "be")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
241 test(int('be', 16), "X", "BE")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
242 test(-int('be', 16), "x", "-be")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
243 test(-int('be', 16), "X", "-BE")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
244
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
245 # octal
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
246 test(3, "o", "3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
247 test(-3, "o", "-3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
248 test(65, "o", "101")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
249 test(-65, "o", "-101")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
250 test(1234, "o", "2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
251 test(-1234, "o", "-2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
252 test(1234, "-o", "2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
253 test(-1234, "-o", "-2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
254 test(1234, " o", " 2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
255 test(-1234, " o", "-2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
256 test(1234, "+o", "+2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
257 test(-1234, "+o", "-2322")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
258
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
259 # binary
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
260 test(3, "b", "11")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
261 test(-3, "b", "-11")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
262 test(1234, "b", "10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
263 test(-1234, "b", "-10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
264 test(1234, "-b", "10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
265 test(-1234, "-b", "-10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
266 test(1234, " b", " 10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
267 test(-1234, " b", "-10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
268 test(1234, "+b", "+10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
269 test(-1234, "+b", "-10011010010")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
270
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
271 # alternate (#) formatting
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
272 test(0, "#b", '0b0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
273 test(0, "-#b", '0b0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
274 test(1, "-#b", '0b1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
275 test(-1, "-#b", '-0b1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
276 test(-1, "-#5b", ' -0b1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
277 test(1, "+#5b", ' +0b1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
278 test(100, "+#b", '+0b1100100')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
279 test(100, "#012b", '0b0001100100')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
280 test(-100, "#012b", '-0b001100100')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
281
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
282 test(0, "#o", '0o0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
283 test(0, "-#o", '0o0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
284 test(1, "-#o", '0o1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
285 test(-1, "-#o", '-0o1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
286 test(-1, "-#5o", ' -0o1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
287 test(1, "+#5o", ' +0o1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
288 test(100, "+#o", '+0o144')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
289 test(100, "#012o", '0o0000000144')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
290 test(-100, "#012o", '-0o000000144')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
291
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
292 test(0, "#x", '0x0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
293 test(0, "-#x", '0x0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
294 test(1, "-#x", '0x1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
295 test(-1, "-#x", '-0x1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
296 test(-1, "-#5x", ' -0x1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
297 test(1, "+#5x", ' +0x1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
298 test(100, "+#x", '+0x64')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
299 test(100, "#012x", '0x0000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
300 test(-100, "#012x", '-0x000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
301 test(123456, "#012x", '0x000001e240')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
302 test(-123456, "#012x", '-0x00001e240')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
303
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
304 test(0, "#X", '0X0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
305 test(0, "-#X", '0X0')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
306 test(1, "-#X", '0X1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
307 test(-1, "-#X", '-0X1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
308 test(-1, "-#5X", ' -0X1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
309 test(1, "+#5X", ' +0X1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
310 test(100, "+#X", '+0X64')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
311 test(100, "#012X", '0X0000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
312 test(-100, "#012X", '-0X000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
313 test(123456, "#012X", '0X000001E240')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
314 test(-123456, "#012X", '-0X00001E240')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
315
52773
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
316 test(123, ',', '123')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
317 test(-123, ',', '-123')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
318 test(1234, ',', '1,234')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
319 test(-1234, ',', '-1,234')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
320 test(123456, ',', '123,456')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
321 test(-123456, ',', '-123,456')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
322 test(1234567, ',', '1,234,567')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
323 test(-1234567, ',', '-1,234,567')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
324
53320
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
325 # issue 5782, commas with no specifier type
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
326 test(1234, '010,', '00,001,234')
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
327
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
328 # Unified type for integers
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
329 test(10**100, 'd', '1' + '0' * 100)
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
330 test(10**100+100, 'd', '1' + '0' * 97 + '100')
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
331
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
332 # make sure these are errors
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
333
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
334 # precision disallowed
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
335 self.assertRaises(ValueError, 3 .__format__, "1.3")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
336 # sign not allowed with 'c'
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
337 self.assertRaises(ValueError, 3 .__format__, "+c")
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
338 # format spec must be string
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
339 self.assertRaises(TypeError, 3 .__format__, None)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
340 self.assertRaises(TypeError, 3 .__format__, 0)
52773
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
341 # can't have ',' with 'n'
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
342 self.assertRaises(ValueError, 3 .__format__, ",n")
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
343 # can't have ',' with 'c'
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
344 self.assertRaises(ValueError, 3 .__format__, ",c")
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
345
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
346 # ensure that only int and float type specifiers work
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
347 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
348 [chr(x) for x in range(ord('A'), ord('Z')+1)]):
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
349 if not format_spec in 'bcdoxXeEfFgGn%':
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
350 self.assertRaises(ValueError, 0 .__format__, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
351 self.assertRaises(ValueError, 1 .__format__, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
352 self.assertRaises(ValueError, (-1) .__format__, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
353
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
354 # ensure that float type specifiers work; format converts
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
355 # the int to a float
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
356 for format_spec in 'eEfFgG%':
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
357 for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]:
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
358 self.assertEqual(value.__format__(format_spec),
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
359 float(value).__format__(format_spec))
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
360
59046
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
361 # Issue 6902
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
362 test(123456, "0<20", '12345600000000000000')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
363 test(123456, "1<20", '12345611111111111111')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
364 test(123456, "*<20", '123456**************')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
365 test(123456, "0>20", '00000000000000123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
366 test(123456, "1>20", '11111111111111123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
367 test(123456, "*>20", '**************123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
368 test(123456, "0=20", '00000000000000123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
369 test(123456, "1=20", '11111111111111123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
370 test(123456, "*=20", '**************123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
371
46601
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
372 @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
373 def test_float__format__locale(self):
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
374 # test locale support for __format__ code 'n'
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
375
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
376 for i in range(-10, 10):
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
377 x = 1234567890.0 * (10.0 ** i)
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
378 self.assertEqual(locale.format('%g', x, grouping=True), format(x, 'n'))
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
379 self.assertEqual(locale.format('%.10g', x, grouping=True), format(x, '.10n'))
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
380
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
381 @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
382 def test_int__format__locale(self):
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
383 # test locale support for __format__ code 'n' for integers
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
384
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
385 x = 123456789012345678901234567890
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
386 for i in range(0, 30):
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
387 self.assertEqual(locale.format('%d', x, grouping=True), format(x, 'n'))
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
388
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
389 # move to the next integer to test
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
390 x = x // 10
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
391
48360
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
392 rfmt = ">20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
393 lfmt = "<20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
394 cfmt = "^20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
395 for x in (1234, 12345, 123456, 1234567, 12345678, 123456789, 1234567890, 12345678900):
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
396 self.assertEqual(len(format(0, rfmt)), len(format(x, rfmt)))
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
397 self.assertEqual(len(format(0, lfmt)), len(format(x, lfmt)))
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
398 self.assertEqual(len(format(0, cfmt)), len(format(x, cfmt)))
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
399
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
400 def test_float__format__(self):
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
401 def test(f, format_spec, result):
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
402 self.assertEqual(f.__format__(format_spec), result)
66444
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
403 self.assertEqual(format(f, format_spec), result)
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
404
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
405 test(0.0, 'f', '0.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
406
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
407 # the default is 'g', except for empty format spec
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
408 test(0.0, '', '0.0')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
409 test(0.01, '', '0.01')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
410 test(0.01, 'g', '0.01')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
411
48537
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
412 # test for issue 3411
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
413 test(1.23, '1', '1.23')
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
414 test(-1.23, '1', '-1.23')
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
415 test(1.23, '1g', '1.23')
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
416 test(-1.23, '1g', '-1.23')
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
417
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
418 test( 1.0, ' g', ' 1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
419 test(-1.0, ' g', '-1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
420 test( 1.0, '+g', '+1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
421 test(-1.0, '+g', '-1')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
422 test(1.1234e200, 'g', '1.1234e+200')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
423 test(1.1234e200, 'G', '1.1234E+200')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
424
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
425
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
426 test(1.0, 'f', '1.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
427
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
428 test(-1.0, 'f', '-1.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
429
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
430 test( 1.0, ' f', ' 1.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
431 test(-1.0, ' f', '-1.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
432 test( 1.0, '+f', '+1.000000')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
433 test(-1.0, '+f', '-1.000000')
53642
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
434
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
435 # Python versions <= 3.0 switched from 'f' to 'g' formatting for
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
436 # values larger than 1e50. No longer.
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
437 f = 1.1234e90
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
438 for fmt in 'f', 'F':
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
439 # don't do a direct equality check, since on some
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
440 # platforms only the first few digits of dtoa
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
441 # will be reliable
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
442 result = f.__format__(fmt)
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
443 self.assertEqual(len(result), 98)
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
444 self.assertEqual(result[-7], '.')
58415
f6a626f34840 use assert[Not]In where appropriate
Benjamin Peterson <benjamin@python.org>
parents: 57582
diff changeset
445 self.assertIn(result[:12], ('112340000000', '112339999999'))
53642
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
446 f = 1.1234e200
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
447 for fmt in 'f', 'F':
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
448 result = f.__format__(fmt)
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
449 self.assertEqual(len(result), 208)
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
450 self.assertEqual(result[-7], '.')
58415
f6a626f34840 use assert[Not]In where appropriate
Benjamin Peterson <benjamin@python.org>
parents: 57582
diff changeset
451 self.assertIn(result[:12], ('112340000000', '112339999999'))
53642
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
452
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
453
45435
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
454 test( 1.0, 'e', '1.000000e+00')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
455 test(-1.0, 'e', '-1.000000e+00')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
456 test( 1.0, 'E', '1.000000E+00')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
457 test(-1.0, 'E', '-1.000000E+00')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
458 test(1.1234e20, 'e', '1.123400e+20')
42b3b117391d Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60875,60880-60881,60886,60888-60890,60892,60894-60898,60900-60931,60933-60958 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45399
diff changeset
459 test(1.1234e20, 'E', '1.123400E+20')
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
460
45852
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
461 # No format code means use g, but must have a decimal
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
462 # and a number after the decimal. This is tricky, because
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
463 # a totaly empty format specifier means something else.
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
464 # So, just use a sign flag
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
465 test(1e200, '+g', '+1e+200')
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
466 test(1e200, '+', '+1e+200')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
467
45852
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
468 test(1.1e200, '+g', '+1.1e+200')
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
469 test(1.1e200, '+', '+1.1e+200')
30c4e1ca8421 Merged revisions 61431,61433-61436,61439,61444,61449-61450,61453,61458,61465,61468,61471-61474,61480,61483-61484,61488,61495-61496,61498,61503-61504,61507,61509-61510,61515-61518 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45435
diff changeset
470
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
471 # 0 padding
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
472 test(1234., '010f', '1234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
473 test(1234., '011f', '1234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
474 test(1234., '012f', '01234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
475 test(-1234., '011f', '-1234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
476 test(-1234., '012f', '-1234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
477 test(-1234., '013f', '-01234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
478 test(-1234.12341234, '013f', '-01234.123412')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
479 test(-123456.12341234, '011.2f', '-0123456.12')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
480
53320
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
481 # issue 5782, commas with no specifier type
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
482 test(1.2, '010,.2', '0,000,001.2')
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
483
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
484 # 0 padding with commas
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
485 test(1234., '011,f', '1,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
486 test(1234., '012,f', '1,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
487 test(1234., '013,f', '01,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
488 test(-1234., '012,f', '-1,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
489 test(-1234., '013,f', '-1,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
490 test(-1234., '014,f', '-01,234.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
491 test(-12345., '015,f', '-012,345.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
492 test(-123456., '016,f', '-0,123,456.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
493 test(-123456., '017,f', '-0,123,456.000000')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
494 test(-123456.12341234, '017,f', '-0,123,456.123412')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
495 test(-123456.12341234, '013,.2f', '-0,123,456.12')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
496
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
497 # % formatting
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
498 test(-1.0, '%', '-100.000000%')
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
499
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
500 # format spec must be string
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
501 self.assertRaises(TypeError, 3.0.__format__, None)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
502 self.assertRaises(TypeError, 3.0.__format__, 0)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
503
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
504 # other format specifiers shouldn't work on floats,
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
505 # in particular int specifiers
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
506 for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
507 [chr(x) for x in range(ord('A'), ord('Z')+1)]):
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
508 if not format_spec in 'eEfFgGn%':
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
509 self.assertRaises(ValueError, format, 0.0, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
510 self.assertRaises(ValueError, format, 1.0, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
511 self.assertRaises(ValueError, format, -1.0, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
512 self.assertRaises(ValueError, format, 1e100, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
513 self.assertRaises(ValueError, format, -1e100, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
514 self.assertRaises(ValueError, format, 1e-100, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
515 self.assertRaises(ValueError, format, -1e-100, format_spec)
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
516
66444
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
517 # Alternate float formatting
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
518 test(1.0, '.0e', '1e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
519 test(1.0, '#.0e', '1.e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
520 test(1.0, '.0f', '1')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
521 test(1.0, '#.0f', '1.')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
522 test(1.1, 'g', '1.1')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
523 test(1.1, '#g', '1.10000')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
524 test(1.0, '.0%', '100%')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
525 test(1.0, '#.0%', '100.%')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
526
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
527 # Issue 7094: Alternate formatting (specified by #)
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
528 test(1.0, '0e', '1.000000e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
529 test(1.0, '#0e', '1.000000e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
530 test(1.0, '0f', '1.000000' )
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
531 test(1.0, '#0f', '1.000000')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
532 test(1.0, '.1e', '1.0e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
533 test(1.0, '#.1e', '1.0e+00')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
534 test(1.0, '.1f', '1.0')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
535 test(1.0, '#.1f', '1.0')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
536 test(1.0, '.1%', '100.0%')
eded691497b7 Issue #7094: Add alternate ('#') flag to __format__ methods for float, complex and Decimal. Allows greater control over when decimal points appear. Added to make transitioning from %-formatting easier. '#g' still has a problem with Decimal which I'll fix soon.
Eric Smith <eric@trueblade.com>
parents: 64283
diff changeset
537 test(1.0, '#.1%', '100.0%')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
538
59046
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
539 # Issue 6902
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
540 test(12345.6, "0<20", '12345.60000000000000')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
541 test(12345.6, "1<20", '12345.61111111111111')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
542 test(12345.6, "*<20", '12345.6*************')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
543 test(12345.6, "0>20", '000000000000012345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
544 test(12345.6, "1>20", '111111111111112345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
545 test(12345.6, "*>20", '*************12345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
546 test(12345.6, "0=20", '000000000000012345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
547 test(12345.6, "1=20", '111111111111112345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
548 test(12345.6, "*=20", '*************12345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
549
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
550 def test_format_spec_errors(self):
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
551 # int, float, and string all share the same format spec
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
552 # mini-language parser.
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
553
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
554 # Check that we can't ask for too many digits. This is
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
555 # probably a CPython specific test. It tries to put the width
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
556 # into a C long.
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
557 self.assertRaises(ValueError, format, 0, '1'*10000 + 'd')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
558
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
559 # Similar with the precision.
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
560 self.assertRaises(ValueError, format, 0, '.' + '1'*10000 + 'd')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
561
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
562 # And may as well test both.
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
563 self.assertRaises(ValueError, format, 0, '1'*1000 + '.' + '1'*10000 + 'd')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
564
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
565 # Make sure commas aren't allowed with various type codes
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
566 for code in 'xXobns':
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
567 self.assertRaises(ValueError, format, 0, ',' + code)
45399
15d5776f2703 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617,60619-60621,60623-60625,60627-60629,60631,60633,60635,60647,60650,60652,60654,60656,60658-60659,60664-60666,60668-60670,60672,60676,60678,60680-60683,60685-60686,60688,60690,60692-60694,60697-60700,60705-60706,60708,60711,60714,60720,60724-60730,60732,60736,60742,60744,60746,60748,60750-60751,60753,60756-60757,60759-60761,60763-60764,60766,60769-60770,60774-60784,60787-60789,60793,60796,60799-60809,60812-60813,60815-60821,60823-60826,60828-60829,60831-60834,60836,60838-60839,60846-60849,60852-60854,60856-60859,60861-60870,60874-60878,60880-60892,60894-60898 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 44160
diff changeset
568
64285
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
569 def test_internal_sizes(self):
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
570 self.assertGreater(object.__basicsize__, 0)
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
571 self.assertGreater(tuple.__itemsize__, 0)
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
572
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
573
76334
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
574 class MappingProxyTests(unittest.TestCase):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
575 mappingproxy = types.MappingProxyType
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
576
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
577 def test_constructor(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
578 class userdict(dict):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
579 pass
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
580
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
581 mapping = {'x': 1, 'y': 2}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
582 self.assertEqual(self.mappingproxy(mapping), mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
583 mapping = userdict(x=1, y=2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
584 self.assertEqual(self.mappingproxy(mapping), mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
585 mapping = collections.ChainMap({'x': 1}, {'y': 2})
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
586 self.assertEqual(self.mappingproxy(mapping), mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
587
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
588 self.assertRaises(TypeError, self.mappingproxy, 10)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
589 self.assertRaises(TypeError, self.mappingproxy, ("a", "tuple"))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
590 self.assertRaises(TypeError, self.mappingproxy, ["a", "list"])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
591
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
592 def test_methods(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
593 attrs = set(dir(self.mappingproxy({}))) - set(dir(object()))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
594 self.assertEqual(attrs, {
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
595 '__contains__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
596 '__getitem__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
597 '__iter__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
598 '__len__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
599 'copy',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
600 'get',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
601 'items',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
602 'keys',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
603 'values',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
604 })
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
605
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
606 def test_get(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
607 view = self.mappingproxy({'a': 'A', 'b': 'B'})
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
608 self.assertEqual(view['a'], 'A')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
609 self.assertEqual(view['b'], 'B')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
610 self.assertRaises(KeyError, view.__getitem__, 'xxx')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
611 self.assertEqual(view.get('a'), 'A')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
612 self.assertIsNone(view.get('xxx'))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
613 self.assertEqual(view.get('xxx', 42), 42)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
614
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
615 def test_missing(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
616 class dictmissing(dict):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
617 def __missing__(self, key):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
618 return "missing=%s" % key
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
619
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
620 view = self.mappingproxy(dictmissing(x=1))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
621 self.assertEqual(view['x'], 1)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
622 self.assertEqual(view['y'], 'missing=y')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
623 self.assertEqual(view.get('x'), 1)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
624 self.assertEqual(view.get('y'), None)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
625 self.assertEqual(view.get('y', 42), 42)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
626 self.assertTrue('x' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
627 self.assertFalse('y' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
628
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
629 def test_customdict(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
630 class customdict(dict):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
631 def __contains__(self, key):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
632 if key == 'magic':
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
633 return True
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
634 else:
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
635 return dict.__contains__(self, key)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
636
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
637 def __iter__(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
638 return iter(('iter',))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
639
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
640 def __len__(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
641 return 500
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
642
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
643 def copy(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
644 return 'copy'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
645
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
646 def keys(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
647 return 'keys'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
648
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
649 def items(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
650 return 'items'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
651
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
652 def values(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
653 return 'values'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
654
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
655 def __getitem__(self, key):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
656 return "getitem=%s" % dict.__getitem__(self, key)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
657
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
658 def get(self, key, default=None):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
659 return "get=%s" % dict.get(self, key, 'default=%r' % default)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
660
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
661 custom = customdict({'key': 'value'})
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
662 view = self.mappingproxy(custom)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
663 self.assertTrue('key' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
664 self.assertTrue('magic' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
665 self.assertFalse('xxx' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
666 self.assertEqual(view['key'], 'getitem=value')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
667 self.assertRaises(KeyError, view.__getitem__, 'xxx')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
668 self.assertEqual(tuple(view), ('iter',))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
669 self.assertEqual(len(view), 500)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
670 self.assertEqual(view.copy(), 'copy')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
671 self.assertEqual(view.get('key'), 'get=value')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
672 self.assertEqual(view.get('xxx'), 'get=default=None')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
673 self.assertEqual(view.items(), 'items')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
674 self.assertEqual(view.keys(), 'keys')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
675 self.assertEqual(view.values(), 'values')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
676
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
677 def test_chainmap(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
678 d1 = {'x': 1}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
679 d2 = {'y': 2}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
680 mapping = collections.ChainMap(d1, d2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
681 view = self.mappingproxy(mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
682 self.assertTrue('x' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
683 self.assertTrue('y' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
684 self.assertFalse('z' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
685 self.assertEqual(view['x'], 1)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
686 self.assertEqual(view['y'], 2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
687 self.assertRaises(KeyError, view.__getitem__, 'z')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
688 self.assertEqual(tuple(sorted(view)), ('x', 'y'))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
689 self.assertEqual(len(view), 2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
690 copy = view.copy()
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
691 self.assertIsNot(copy, mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
692 self.assertIsInstance(copy, collections.ChainMap)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
693 self.assertEqual(copy, mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
694 self.assertEqual(view.get('x'), 1)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
695 self.assertEqual(view.get('y'), 2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
696 self.assertIsNone(view.get('z'))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
697 self.assertEqual(tuple(sorted(view.items())), (('x', 1), ('y', 2)))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
698 self.assertEqual(tuple(sorted(view.keys())), ('x', 'y'))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
699 self.assertEqual(tuple(sorted(view.values())), (1, 2))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
700
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
701 def test_contains(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
702 view = self.mappingproxy(dict.fromkeys('abc'))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
703 self.assertTrue('a' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
704 self.assertTrue('b' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
705 self.assertTrue('c' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
706 self.assertFalse('xxx' in view)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
707
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
708 def test_views(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
709 mapping = {}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
710 view = self.mappingproxy(mapping)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
711 keys = view.keys()
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
712 values = view.values()
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
713 items = view.items()
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
714 self.assertEqual(list(keys), [])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
715 self.assertEqual(list(values), [])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
716 self.assertEqual(list(items), [])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
717 mapping['key'] = 'value'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
718 self.assertEqual(list(keys), ['key'])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
719 self.assertEqual(list(values), ['value'])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
720 self.assertEqual(list(items), [('key', 'value')])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
721
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
722 def test_len(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
723 for expected in range(6):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
724 data = dict.fromkeys('abcde'[:expected])
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
725 self.assertEqual(len(data), expected)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
726 view = self.mappingproxy(data)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
727 self.assertEqual(len(view), expected)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
728
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
729 def test_iterators(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
730 keys = ('x', 'y')
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
731 values = (1, 2)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
732 items = tuple(zip(keys, values))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
733 view = self.mappingproxy(dict(items))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
734 self.assertEqual(set(view), set(keys))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
735 self.assertEqual(set(view.keys()), set(keys))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
736 self.assertEqual(set(view.values()), set(values))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
737 self.assertEqual(set(view.items()), set(items))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
738
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
739 def test_copy(self):
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
740 original = {'key1': 27, 'key2': 51, 'key3': 93}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
741 view = self.mappingproxy(original)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
742 copy = view.copy()
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
743 self.assertEqual(type(copy), dict)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
744 self.assertEqual(copy, original)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
745 original['key1'] = 70
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
746 self.assertEqual(view['key1'], 70)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
747 self.assertEqual(copy['key1'], 27)
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
748
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
749
77059
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
750 class ClassCreationTests(unittest.TestCase):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
751
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
752 class Meta(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
753 def __init__(cls, name, bases, ns, **kw):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
754 super().__init__(name, bases, ns)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
755 @staticmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
756 def __new__(mcls, name, bases, ns, **kw):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
757 return super().__new__(mcls, name, bases, ns)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
758 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
759 def __prepare__(mcls, name, bases, **kw):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
760 ns = super().__prepare__(name, bases)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
761 ns["y"] = 1
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
762 ns.update(kw)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
763 return ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
764
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
765 def test_new_class_basics(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
766 C = types.new_class("C")
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
767 self.assertEqual(C.__name__, "C")
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
768 self.assertEqual(C.__bases__, (object,))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
769
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
770 def test_new_class_subclass(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
771 C = types.new_class("C", (int,))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
772 self.assertTrue(issubclass(C, int))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
773
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
774 def test_new_class_meta(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
775 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
776 settings = {"metaclass": Meta, "z": 2}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
777 # We do this twice to make sure the passed in dict isn't mutated
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
778 for i in range(2):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
779 C = types.new_class("C" + str(i), (), settings)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
780 self.assertIsInstance(C, Meta)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
781 self.assertEqual(C.y, 1)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
782 self.assertEqual(C.z, 2)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
783
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
784 def test_new_class_exec_body(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
785 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
786 def func(ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
787 ns["x"] = 0
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
788 C = types.new_class("C", (), {"metaclass": Meta, "z": 2}, func)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
789 self.assertIsInstance(C, Meta)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
790 self.assertEqual(C.x, 0)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
791 self.assertEqual(C.y, 1)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
792 self.assertEqual(C.z, 2)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
793
79199
e99c0425da59 renmae test method to avoid conflict (#16056)
Benjamin Peterson <benjamin@python.org>
parents: 77339
diff changeset
794 def test_new_class_metaclass_keywords(self):
77059
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
795 #Test that keywords are passed to the metaclass:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
796 def meta_func(name, bases, ns, **kw):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
797 return name, bases, ns, kw
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
798 res = types.new_class("X",
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
799 (int, object),
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
800 dict(metaclass=meta_func, x=0))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
801 self.assertEqual(res, ("X", (int, object), {}, {"x": 0}))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
802
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
803 def test_new_class_defaults(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
804 # Test defaults/keywords:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
805 C = types.new_class("C", (), {}, None)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
806 self.assertEqual(C.__name__, "C")
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
807 self.assertEqual(C.__bases__, (object,))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
808
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
809 def test_new_class_meta_with_base(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
810 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
811 def func(ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
812 ns["x"] = 0
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
813 C = types.new_class(name="C",
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
814 bases=(int,),
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
815 kwds=dict(metaclass=Meta, z=2),
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
816 exec_body=func)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
817 self.assertTrue(issubclass(C, int))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
818 self.assertIsInstance(C, Meta)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
819 self.assertEqual(C.x, 0)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
820 self.assertEqual(C.y, 1)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
821 self.assertEqual(C.z, 2)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
822
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
823 # Many of the following tests are derived from test_descr.py
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
824 def test_prepare_class(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
825 # Basic test of metaclass derivation
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
826 expected_ns = {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
827 class A(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
828 def __new__(*args, **kwargs):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
829 return type.__new__(*args, **kwargs)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
830
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
831 def __prepare__(*args):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
832 return expected_ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
833
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
834 B = types.new_class("B", (object,))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
835 C = types.new_class("C", (object,), {"metaclass": A})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
836
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
837 # The most derived metaclass of D is A rather than type.
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
838 meta, ns, kwds = types.prepare_class("D", (B, C), {"metaclass": type})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
839 self.assertIs(meta, A)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
840 self.assertIs(ns, expected_ns)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
841 self.assertEqual(len(kwds), 0)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
842
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
843 def test_metaclass_derivation(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
844 # issue1294232: correct metaclass calculation
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
845 new_calls = [] # to check the order of __new__ calls
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
846 class AMeta(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
847 def __new__(mcls, name, bases, ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
848 new_calls.append('AMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
849 return super().__new__(mcls, name, bases, ns)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
850 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
851 def __prepare__(mcls, name, bases):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
852 return {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
853
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
854 class BMeta(AMeta):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
855 def __new__(mcls, name, bases, ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
856 new_calls.append('BMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
857 return super().__new__(mcls, name, bases, ns)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
858 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
859 def __prepare__(mcls, name, bases):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
860 ns = super().__prepare__(name, bases)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
861 ns['BMeta_was_here'] = True
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
862 return ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
863
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
864 A = types.new_class("A", (), {"metaclass": AMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
865 self.assertEqual(new_calls, ['AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
866 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
867
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
868 B = types.new_class("B", (), {"metaclass": BMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
869 # BMeta.__new__ calls AMeta.__new__ with super:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
870 self.assertEqual(new_calls, ['BMeta', 'AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
871 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
872
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
873 C = types.new_class("C", (A, B))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
874 # The most derived metaclass is BMeta:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
875 self.assertEqual(new_calls, ['BMeta', 'AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
876 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
877 # BMeta.__prepare__ should've been called:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
878 self.assertIn('BMeta_was_here', C.__dict__)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
879
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
880 # The order of the bases shouldn't matter:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
881 C2 = types.new_class("C2", (B, A))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
882 self.assertEqual(new_calls, ['BMeta', 'AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
883 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
884 self.assertIn('BMeta_was_here', C2.__dict__)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
885
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
886 # Check correct metaclass calculation when a metaclass is declared:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
887 D = types.new_class("D", (C,), {"metaclass": type})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
888 self.assertEqual(new_calls, ['BMeta', 'AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
889 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
890 self.assertIn('BMeta_was_here', D.__dict__)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
891
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
892 E = types.new_class("E", (C,), {"metaclass": AMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
893 self.assertEqual(new_calls, ['BMeta', 'AMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
894 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
895 self.assertIn('BMeta_was_here', E.__dict__)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
896
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
897 def test_metaclass_override_function(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
898 # Special case: the given metaclass isn't a class,
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
899 # so there is no metaclass calculation.
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
900 class A(metaclass=self.Meta):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
901 pass
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
902
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
903 marker = object()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
904 def func(*args, **kwargs):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
905 return marker
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
906
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
907 X = types.new_class("X", (), {"metaclass": func})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
908 Y = types.new_class("Y", (object,), {"metaclass": func})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
909 Z = types.new_class("Z", (A,), {"metaclass": func})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
910 self.assertIs(marker, X)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
911 self.assertIs(marker, Y)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
912 self.assertIs(marker, Z)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
913
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
914 def test_metaclass_override_callable(self):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
915 # The given metaclass is a class,
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
916 # but not a descendant of type.
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
917 new_calls = [] # to check the order of __new__ calls
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
918 prepare_calls = [] # to track __prepare__ calls
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
919 class ANotMeta:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
920 def __new__(mcls, *args, **kwargs):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
921 new_calls.append('ANotMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
922 return super().__new__(mcls)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
923 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
924 def __prepare__(mcls, name, bases):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
925 prepare_calls.append('ANotMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
926 return {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
927
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
928 class BNotMeta(ANotMeta):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
929 def __new__(mcls, *args, **kwargs):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
930 new_calls.append('BNotMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
931 return super().__new__(mcls)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
932 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
933 def __prepare__(mcls, name, bases):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
934 prepare_calls.append('BNotMeta')
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
935 return super().__prepare__(name, bases)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
936
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
937 A = types.new_class("A", (), {"metaclass": ANotMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
938 self.assertIs(ANotMeta, type(A))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
939 self.assertEqual(prepare_calls, ['ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
940 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
941 self.assertEqual(new_calls, ['ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
942 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
943
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
944 B = types.new_class("B", (), {"metaclass": BNotMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
945 self.assertIs(BNotMeta, type(B))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
946 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
947 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
948 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
949 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
950
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
951 C = types.new_class("C", (A, B))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
952 self.assertIs(BNotMeta, type(C))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
953 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
954 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
955 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
956 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
957
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
958 C2 = types.new_class("C2", (B, A))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
959 self.assertIs(BNotMeta, type(C2))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
960 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
961 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
962 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
963 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
964
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
965 # This is a TypeError, because of a metaclass conflict:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
966 # BNotMeta is neither a subclass, nor a superclass of type
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
967 with self.assertRaises(TypeError):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
968 D = types.new_class("D", (C,), {"metaclass": type})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
969
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
970 E = types.new_class("E", (C,), {"metaclass": ANotMeta})
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
971 self.assertIs(BNotMeta, type(E))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
972 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
973 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
974 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
975 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
976
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
977 F = types.new_class("F", (object(), C))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
978 self.assertIs(BNotMeta, type(F))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
979 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
980 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
981 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
982 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
983
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
984 F2 = types.new_class("F2", (C, object()))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
985 self.assertIs(BNotMeta, type(F2))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
986 self.assertEqual(prepare_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
987 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
988 self.assertEqual(new_calls, ['BNotMeta', 'ANotMeta'])
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
989 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
990
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
991 # TypeError: BNotMeta is neither a
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
992 # subclass, nor a superclass of int
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
993 with self.assertRaises(TypeError):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
994 X = types.new_class("X", (C, int()))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
995 with self.assertRaises(TypeError):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
996 X = types.new_class("X", (int(), C))
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
997
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
998
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
999 class SimpleNamespaceTests(unittest.TestCase):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1000
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1001 def test_constructor(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1002 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1003 ns2 = types.SimpleNamespace(x=1, y=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1004 ns3 = types.SimpleNamespace(**dict(x=1, y=2))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1005
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1006 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1007 types.SimpleNamespace(1, 2, 3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1008
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1009 self.assertEqual(len(ns1.__dict__), 0)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1010 self.assertEqual(vars(ns1), {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1011 self.assertEqual(len(ns2.__dict__), 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1012 self.assertEqual(vars(ns2), {'y': 2, 'x': 1})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1013 self.assertEqual(len(ns3.__dict__), 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1014 self.assertEqual(vars(ns3), {'y': 2, 'x': 1})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1015
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1016 def test_unbound(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1017 ns1 = vars(types.SimpleNamespace())
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1018 ns2 = vars(types.SimpleNamespace(x=1, y=2))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1019
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1020 self.assertEqual(ns1, {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1021 self.assertEqual(ns2, {'y': 2, 'x': 1})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1022
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1023 def test_underlying_dict(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1024 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1025 ns2 = types.SimpleNamespace(x=1, y=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1026 ns3 = types.SimpleNamespace(a=True, b=False)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1027 mapping = ns3.__dict__
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1028 del ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1029
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1030 self.assertEqual(ns1.__dict__, {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1031 self.assertEqual(ns2.__dict__, {'y': 2, 'x': 1})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1032 self.assertEqual(mapping, dict(a=True, b=False))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1033
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1034 def test_attrget(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1035 ns = types.SimpleNamespace(x=1, y=2, w=3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1036
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1037 self.assertEqual(ns.x, 1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1038 self.assertEqual(ns.y, 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1039 self.assertEqual(ns.w, 3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1040 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1041 ns.z
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1042
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1043 def test_attrset(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1044 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1045 ns2 = types.SimpleNamespace(x=1, y=2, w=3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1046 ns1.a = 'spam'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1047 ns1.b = 'ham'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1048 ns2.z = 4
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1049 ns2.theta = None
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1050
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1051 self.assertEqual(ns1.__dict__, dict(a='spam', b='ham'))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1052 self.assertEqual(ns2.__dict__, dict(x=1, y=2, w=3, z=4, theta=None))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1053
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1054 def test_attrdel(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1055 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1056 ns2 = types.SimpleNamespace(x=1, y=2, w=3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1057
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1058 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1059 del ns1.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1060 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1061 del ns2.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1062
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1063 del ns2.y
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1064 self.assertEqual(vars(ns2), dict(w=3, x=1))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1065 ns2.y = 'spam'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1066 self.assertEqual(vars(ns2), dict(w=3, x=1, y='spam'))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1067 del ns2.y
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1068 self.assertEqual(vars(ns2), dict(w=3, x=1))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1069
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1070 ns1.spam = 5
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1071 self.assertEqual(vars(ns1), dict(spam=5))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1072 del ns1.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1073 self.assertEqual(vars(ns1), {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1074
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1075 def test_repr(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1076 ns1 = types.SimpleNamespace(x=1, y=2, w=3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1077 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1078 ns2.x = "spam"
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1079 ns2._y = 5
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1080
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1081 self.assertEqual(repr(ns1), "namespace(w=3, x=1, y=2)")
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1082 self.assertEqual(repr(ns2), "namespace(_y=5, x='spam')")
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1083
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1084 def test_nested(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1085 ns1 = types.SimpleNamespace(a=1, b=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1086 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1087 ns3 = types.SimpleNamespace(x=ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1088 ns2.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1089 ns2.ham = '?'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1090 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1091
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1092 self.assertEqual(vars(ns1), dict(a=1, b=2))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1093 self.assertEqual(vars(ns2), dict(spam=ns3, ham='?'))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1094 self.assertEqual(ns2.spam, ns3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1095 self.assertEqual(vars(ns3), dict(x=ns1))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1096 self.assertEqual(ns3.x.a, 1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1097
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1098 def test_recursive(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1099 ns1 = types.SimpleNamespace(c='cookie')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1100 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1101 ns3 = types.SimpleNamespace(x=1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1102 ns1.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1103 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1104 ns3.spam = ns2
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1105
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1106 self.assertEqual(ns1.spam, ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1107 self.assertEqual(ns1.spam.spam, ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1108 self.assertEqual(ns1.spam.spam, ns1.spam)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1109 self.assertEqual(ns2.spam, ns3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1110 self.assertEqual(ns3.spam, ns2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1111 self.assertEqual(ns2.spam.spam, ns2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1112
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1113 def test_recursive_repr(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1114 ns1 = types.SimpleNamespace(c='cookie')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1115 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1116 ns3 = types.SimpleNamespace(x=1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1117 ns1.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1118 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1119 ns3.spam = ns2
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1120
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1121 self.assertEqual(repr(ns1),
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1122 "namespace(c='cookie', spam=namespace(...))")
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1123 self.assertEqual(repr(ns2),
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1124 "namespace(spam=namespace(spam=namespace(...), x=1))")
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1125
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1126 def test_as_dict(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1127 ns = types.SimpleNamespace(spam='spamspamspam')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1128
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1129 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1130 len(ns)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1131 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1132 iter(ns)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1133 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1134 'spam' in ns
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1135 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1136 ns['spam']
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1137
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1138
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1139 def test_main():
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1140 run_unittest(TypesTests, MappingProxyTests, ClassCreationTests,
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1141 SimpleNamespaceTests)
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1142
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1143 if __name__ == '__main__':
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1144 test_main()