annotate Lib/test/test_types.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents e4c065b2db49
children
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
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
5 import pickle
76334
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
6 import locale
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
7 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
8 import types
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
9 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
10
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
11 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
12
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
13 def test_truth_values(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
14 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
15 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
16 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
17 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
18 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
19 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
20 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
21 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
22 def f(): pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
23 class C: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
24 x = C()
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
25 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
26 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
27 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
28 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
29
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
30 def test_boolean_ops(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
31 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
32 if 1 and 1: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
33 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
34 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
35
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
36 def test_comparisons(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
37 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
38 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
39 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
40 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
41 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
42 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
43 if None is None: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
44 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
45
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
46 def test_float_constructor(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
47 self.assertRaises(ValueError, float, '')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
48 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
49
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
50 def test_zero_division(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
51 try: 5.0 / 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
52 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
53 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
54
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
55 try: 5.0 // 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
56 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
57 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
58
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
59 try: 5.0 % 0.0
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
60 except ZeroDivisionError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
61 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
62
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
63 try: 5 / 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
64 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
65 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
66
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
67 try: 5 // 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
68 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
69 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
70
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
71 try: 5 % 0
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
72 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
73 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
74
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
75 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
76 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
77 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
78 # 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
79 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
80 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
81 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
82 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
83 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
84 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
85
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
86 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
87 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
88 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
89 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
90
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 # 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
92 # '%' 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
93 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
94 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
95
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 # 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
97 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
98 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
99
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(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
101 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
102
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(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
104 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
105
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(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
107 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
108
53187
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')
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
110 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
111
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
112 def test_normal_integers(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
113 # 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
114 a = 256
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
115 b = 128*2
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
116 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
117 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
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 != 12: 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 (-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
121 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
122 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
123 # 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
124 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
125 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
126 self.fail('int mul commutativity')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
127 # And another.
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
128 m = -sys.maxsize - 1
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
129 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
130 j = m // divisor
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
131 prod = divisor * j
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
132 if prod != m:
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
133 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
134 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
135 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
136 type(prod))
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
137 # 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
138 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
139 j = m // divisor - 1
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
140 prod = divisor * j
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
141 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
142 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
143 (prod, type(prod)))
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
144 # Check for unified integral type
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
145 m = sys.maxsize
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
146 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
147 j = m // divisor + 1
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
148 prod = divisor * j
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 40450
diff changeset
149 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
150 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
151 (prod, type(prod)))
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
152
44160
9d152530910a Removed PyInt_GetMax and sys.maxint
Christian Heimes <christian@cheimes.de>
parents: 43487
diff changeset
153 x = sys.maxsize
58473
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
154 self.assertIsInstance(x + 1, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
155 "(sys.maxsize + 1) should have returned int")
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
156 self.assertIsInstance(-x - 1, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
157 "(-sys.maxsize - 1) should have returned int")
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
158 self.assertIsInstance(-x - 2, int,
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 58415
diff changeset
159 "(-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
160
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
161 try: 5 << -5
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
162 except ValueError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
163 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
164
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
165 try: 5 >> -5
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
166 except ValueError: pass
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
167 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
168
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
169 def test_floats(self):
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 != 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
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 != 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
173 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
174 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
175 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
176
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
177 def test_strings(self):
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
178 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
179 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
180 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
181 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
182 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
183 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
184 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
185 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
186 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
187 x = 'x'*103
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
188 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
189
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
190 #extended slices for strings
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
191 a = '0123456789'
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
192 self.assertEqual(a[::], a)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
193 self.assertEqual(a[::2], '02468')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
194 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
195 self.assertEqual(a[::-1],'9876543210')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
196 self.assertEqual(a[::-2], '97531')
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
197 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
198 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
199 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
200 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
201
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
202 def test_type_function(self):
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)
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
204 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
205
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
206 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
207 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
208 # 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
209 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
210 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
211 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
212
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 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
215
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 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
217
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 # 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
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, "-", '-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, " 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
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 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
229
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 # 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
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(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
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, "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
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, "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
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(-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
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(-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
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 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
245
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 # 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
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(-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
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(-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
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 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
259
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 # 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
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(-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
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 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
271
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
272 # alternate (#) formatting
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(0, "-#b", '0b0')
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, "-#b", '-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(1, "+#5b", ' +0b1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
279 test(100, "+#b", '+0b1100100')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
280 test(100, "#012b", '0b0001100100')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
281 test(-100, "#012b", '-0b001100100')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
282
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(0, "-#o", '0o0')
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, "-#o", '-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(1, "+#5o", ' +0o1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
289 test(100, "+#o", '+0o144')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
290 test(100, "#012o", '0o0000000144')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
291 test(-100, "#012o", '-0o000000144')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
292
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(0, "-#x", '0x0')
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, "-#x", '-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(1, "+#5x", ' +0x1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
299 test(100, "+#x", '+0x64')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
300 test(100, "#012x", '0x0000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
301 test(-100, "#012x", '-0x000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
302 test(123456, "#012x", '0x000001e240')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
303 test(-123456, "#012x", '-0x00001e240')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
304
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(0, "-#X", '0X0')
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, "-#X", '-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(1, "+#5X", ' +0X1')
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
311 test(100, "+#X", '+0X64')
48482
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
312 test(100, "#012X", '0X0000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
313 test(-100, "#012X", '-0X000000064')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
314 test(123456, "#012X", '0X000001E240')
c662e8cffddf Merged revisions 64984 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48472
diff changeset
315 test(-123456, "#012X", '-0X00001E240')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
316
52773
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(-123, ',', '-123')
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(-1234, ',', '-1,234')
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(-123456, ',', '-123,456')
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 test(-1234567, ',', '-1,234,567')
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
325
53320
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
326 # issue 5782, commas with no specifier type
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
327 test(1234, '010,', '00,001,234')
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
328
57582
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
329 # Unified type for integers
1c92fbb3baf2 Issue #7435: Remove duplicate int/long tests, and other
Mark Dickinson <dickinsm@gmail.com>
parents: 55593
diff changeset
330 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
331 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
332
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
333 # 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
334
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 # 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
336 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
337 # 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
338 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
339 # 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
340 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
341 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
342 # can't have ',' with 'n'
28096ed73153 Added ',' thousands grouping to int.__format__. See PEP 378.
Eric Smith <eric@trueblade.com>
parents: 48537
diff changeset
343 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
344 # 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
345 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
346
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 # 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
348 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
349 [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
350 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
351 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
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 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
354
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 # 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
356 # the int to a float
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
357 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
358 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
359 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
360 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
361
59046
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
362 # Issue 6902
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
363 test(123456, "0<20", '12345600000000000000')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
364 test(123456, "1<20", '12345611111111111111')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
365 test(123456, "*<20", '123456**************')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
366 test(123456, "0>20", '00000000000000123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
367 test(123456, "1>20", '11111111111111123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
368 test(123456, "*>20", '**************123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
369 test(123456, "0=20", '00000000000000123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
370 test(123456, "1=20", '11111111111111123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
371 test(123456, "*=20", '**************123456')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
372
46601
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
373 @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
374 def test_float__format__locale(self):
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
375 # test locale support for __format__ code 'n'
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
376
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
377 for i in range(-10, 10):
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
378 x = 1234567890.0 * (10.0 ** i)
7b4081bec783 Merged revisions 62586 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 45852
diff changeset
379 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
380 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
381
46909
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
382 @run_with_locale('LC_NUMERIC', 'en_US.UTF8')
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
383 def test_int__format__locale(self):
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
384 # 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
385
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
386 x = 123456789012345678901234567890
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
387 for i in range(0, 30):
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
388 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
389
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
390 # move to the next integer to test
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
391 x = x // 10
ef4ec968fdb6 Merged revisions 63078 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 46601
diff changeset
392
48360
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
393 rfmt = ">20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
394 lfmt = "<20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
395 cfmt = "^20n"
7e747de231b3 Merged revisions 64499 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 47201
diff changeset
396 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
397 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
398 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
399 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
400
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
401 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
402 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
403 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
404 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
405
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 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
407
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 # 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
409 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
410 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
411 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
412
48537
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
413 # test for issue 3411
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, '1', '-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 test(-1.23, '1g', '-1.23')
48e83e66935a Merged revisions 65125 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 48523
diff changeset
418
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
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.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
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 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
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
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 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
428
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 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
430
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')
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
434 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
435
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
436 # 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
437 # 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
438 f = 1.1234e90
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
439 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
440 # 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
441 # 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
442 # will be reliable
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
443 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
444 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
445 self.assertEqual(result[-7], '.')
58415
f6a626f34840 use assert[Not]In where appropriate
Benjamin Peterson <benjamin@python.org>
parents: 57582
diff changeset
446 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
447 f = 1.1234e200
60d0f373a894 Issue #5859: Remove '%f' to '%g' formatting switch for large floats.
Mark Dickinson <dickinsm@gmail.com>
parents: 53320
diff changeset
448 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
449 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
450 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
451 self.assertEqual(result[-7], '.')
58415
f6a626f34840 use assert[Not]In where appropriate
Benjamin Peterson <benjamin@python.org>
parents: 57582
diff changeset
452 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
453
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
454
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
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.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
459 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
460 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
461
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
462 # 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
463 # 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
464 # 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
465 # 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
466 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
467 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
468
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
469 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
470 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
471
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
472 # 0 padding
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., '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
474 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
475 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
476 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
477 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
478 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
479 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
480 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
481
53320
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
482 # issue 5782, commas with no specifier type
513dc6fa61c0 Merged revisions 71802 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 53187
diff changeset
483 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
484
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
485 # 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
486 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
487 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
488 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
489 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
490 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
491 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
492 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
493 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
494 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
495 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
496 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
497
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
498 # % 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
499 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
500
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 # 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
502 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
503 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
504
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 # 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
506 # 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
507 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
508 [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
509 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
510 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
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, -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
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, -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
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 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
517
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
518 # 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
519 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
520 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
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.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
523 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
524 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
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 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
527
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 # 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
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, '#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
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, '#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
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, '#.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
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, '#.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
537 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
538 test(1.0, '#.1%', '100.0%')
48472
d4e473291a17 Forward port of r64958.
Eric Smith <eric@trueblade.com>
parents: 48360
diff changeset
539
59046
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
540 # Issue 6902
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
541 test(12345.6, "0<20", '12345.60000000000000')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
542 test(12345.6, "1<20", '12345.61111111111111')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
543 test(12345.6, "*<20", '12345.6*************')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
544 test(12345.6, "0>20", '000000000000012345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
545 test(12345.6, "1>20", '111111111111112345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
546 test(12345.6, "*>20", '*************12345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
547 test(12345.6, "0=20", '000000000000012345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
548 test(12345.6, "1=20", '111111111111112345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
549 test(12345.6, "*=20", '*************12345.6')
8e8c45ab44dc Merged revisions 78350 via svnmerge from
Eric Smith <eric@trueblade.com>
parents: 55593
diff changeset
550
53187
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
551 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
552 # 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
553 # 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
554
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
555 # 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
556 # 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
557 # 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
558 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
559
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
560 # 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
561 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
562
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
563 # 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
564 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
565
b653eab13b73 The other half of Issue #1580: use short float repr where possible.
Eric Smith <eric@trueblade.com>
parents: 52773
diff changeset
566 # 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
567 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
568 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
569
64285
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
570 def test_internal_sizes(self):
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
571 self.assertGreater(object.__basicsize__, 0)
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
572 self.assertGreater(tuple.__itemsize__, 0)
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
573
190375445241 Merged revisions 84320 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 59046
diff changeset
574
76334
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
575 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
576 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
577
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
578 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
579 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
580 pass
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
581
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
582 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
583 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
584 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
585 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
586 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
587 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
588
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, 10)
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", "tuple"))
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
591 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
592
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
593 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
594 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
595 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
596 '__contains__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
597 '__getitem__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
598 '__iter__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
599 '__len__',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
600 'copy',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
601 'get',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
602 'items',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
603 'keys',
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
604 'values',
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
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614 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
615
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
616 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
617 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
618 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
619 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
620
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
621 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
622 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
623 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
624 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
625 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
626 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
627 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
628 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
629
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
630 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
631 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
632 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
633 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
634 return True
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
635 else:
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
636 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
637
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
638 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
639 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
640
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
641 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
642 return 500
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
643
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
644 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
645 return 'copy'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
646
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
647 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
648 return 'keys'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
649
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
650 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
651 return 'items'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
652
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
653 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
654 return 'values'
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
655
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
656 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
657 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
658
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
659 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
660 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
661
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
662 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
663 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
664 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
665 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
666 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
667 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
668 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
669 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
670 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
671 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
672 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
673 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
674 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
675 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
676 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
677
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
678 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
679 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
680 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
681 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
682 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
683 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
684 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
685 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
686 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
687 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
688 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
689 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
690 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
691 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
692 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
693 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
694 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
695 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
696 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
697 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
698 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
699 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
700 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
701
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
702 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
703 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
704 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
705 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
706 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
707 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
708
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
709 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
710 mapping = {}
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
711 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
712 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
713 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
714 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
715 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
716 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
717 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
718 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
719 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
720 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
721 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
722
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
723 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
724 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
725 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
726 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
727 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
728 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
729
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
730 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
731 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
732 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
733 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
734 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
735 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
736 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
737 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
738 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
739
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
740 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
741 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
742 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
743 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
744 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
745 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
746 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
747 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
748 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
749
c3a0197256ee Issue #14386: Expose the dict_proxy internal type as types.MappingProxyType
Victor Stinner <victor.stinner@gmail.com>
parents: 68257
diff changeset
750
77059
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
751 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
752
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
753 class Meta(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
754 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
755 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
756 @staticmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
757 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
758 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
759 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
760 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
761 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
762 ns["y"] = 1
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
763 ns.update(kw)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
764 return ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
765
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
766 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
767 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
768 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
769 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
770
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
771 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
772 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
773 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
774
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
775 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
776 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
777 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
778 # 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
779 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
780 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
781 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
782 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
783 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
784
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
785 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
786 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
787 def func(ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
788 ns["x"] = 0
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
789 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
790 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
791 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
792 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
793 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
794
79199
e99c0425da59 renmae test method to avoid conflict (#16056)
Benjamin Peterson <benjamin@python.org>
parents: 77339
diff changeset
795 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
796 #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
797 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
798 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
799 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
800 (int, object),
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
801 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
802 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
803
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
804 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
805 # Test defaults/keywords:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
806 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
807 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
808 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
809
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
810 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
811 Meta = self.Meta
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
812 def func(ns):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
813 ns["x"] = 0
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
814 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
815 bases=(int,),
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
816 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
817 exec_body=func)
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
818 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
819 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
820 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
821 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
822 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
823
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
824 # 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
825 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
826 # 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
827 expected_ns = {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
828 class A(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
829 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
830 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
831
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
832 def __prepare__(*args):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
833 return expected_ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
834
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
835 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
836 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
837
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
838 # 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
839 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
840 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
841 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
842 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
843
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
844 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
845 # 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
846 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
847 class AMeta(type):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
848 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
849 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
850 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
851 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
852 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
853 return {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
854
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
855 class BMeta(AMeta):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
856 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
857 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
858 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
859 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
860 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
861 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
862 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
863 return ns
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
864
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
865 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
866 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
867 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
868
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
869 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
870 # 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
871 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
872 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
873
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
874 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
875 # 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
876 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
877 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
878 # 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
879 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
880
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
881 # 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
882 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
883 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
884 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
885 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
886
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
887 # 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
888 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
889 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
890 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
891 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
892
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
893 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
894 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
895 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
896 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
897
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
898 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
899 # 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
900 # 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
901 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
902 pass
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
903
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
904 marker = object()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
905 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
906 return marker
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
907
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
908 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
909 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
910 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
911 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
912 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
913 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
914
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
915 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
916 # 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
917 # 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
918 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
919 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
920 class ANotMeta:
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
921 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
922 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
923 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
924 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
925 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
926 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
927 return {}
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
928
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
929 class BNotMeta(ANotMeta):
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
930 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
931 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
932 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
933 @classmethod
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
934 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
935 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
936 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
937
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
938 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
939 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
940 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
941 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
942 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
943 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
944
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
945 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
946 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
947 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
948 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
949 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
950 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
951
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
952 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
953 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
954 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
955 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
956 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
957 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
958
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
959 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
960 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
961 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
962 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
963 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
964 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
965
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
966 # 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
967 # 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
968 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
969 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
970
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
971 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
972 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
973 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
974 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
975 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
976 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
977
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
978 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
979 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
980 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
981 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
982 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
983 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
984
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
985 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
986 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
987 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
988 prepare_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
989 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
990 new_calls.clear()
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
991
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
992 # 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
993 # 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
994 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
995 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
996 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
997 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
998
befd56673c80 Close #14588: added a PEP 3115 compliant dynamic type creation mechanism
Nick Coghlan <ncoghlan@gmail.com>
parents: 76334
diff changeset
999
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1000 class SimpleNamespaceTests(unittest.TestCase):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1001
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1002 def test_constructor(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1003 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1004 ns2 = types.SimpleNamespace(x=1, y=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1005 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
1006
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1007 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1008 types.SimpleNamespace(1, 2, 3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1009
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1010 self.assertEqual(len(ns1.__dict__), 0)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1011 self.assertEqual(vars(ns1), {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1012 self.assertEqual(len(ns2.__dict__), 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1013 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
1014 self.assertEqual(len(ns3.__dict__), 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1015 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
1016
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1017 def test_unbound(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1018 ns1 = vars(types.SimpleNamespace())
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1019 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
1020
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1021 self.assertEqual(ns1, {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1022 self.assertEqual(ns2, {'y': 2, 'x': 1})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1023
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1024 def test_underlying_dict(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1025 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1026 ns2 = types.SimpleNamespace(x=1, y=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1027 ns3 = types.SimpleNamespace(a=True, b=False)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1028 mapping = ns3.__dict__
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1029 del ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1030
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1031 self.assertEqual(ns1.__dict__, {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1032 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
1033 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
1034
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1035 def test_attrget(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1036 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
1037
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1038 self.assertEqual(ns.x, 1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1039 self.assertEqual(ns.y, 2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1040 self.assertEqual(ns.w, 3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1041 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1042 ns.z
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1043
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1044 def test_attrset(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1045 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1046 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
1047 ns1.a = 'spam'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1048 ns1.b = 'ham'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1049 ns2.z = 4
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1050 ns2.theta = None
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1051
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1052 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
1053 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
1054
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1055 def test_attrdel(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1056 ns1 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1057 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
1058
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1059 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1060 del ns1.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1061 with self.assertRaises(AttributeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1062 del ns2.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1063
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1064 del ns2.y
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1065 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
1066 ns2.y = 'spam'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1067 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
1068 del ns2.y
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1069 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
1070
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1071 ns1.spam = 5
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1072 self.assertEqual(vars(ns1), dict(spam=5))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1073 del ns1.spam
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1074 self.assertEqual(vars(ns1), {})
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1075
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1076 def test_repr(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1077 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
1078 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1079 ns2.x = "spam"
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1080 ns2._y = 5
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1081 name = "namespace"
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1082
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1083 self.assertEqual(repr(ns1), "{name}(w=3, x=1, y=2)".format(name=name))
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1084 self.assertEqual(repr(ns2), "{name}(_y=5, x='spam')".format(name=name))
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1085
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1086 def test_equal(self):
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1087 ns1 = types.SimpleNamespace(x=1)
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1088 ns2 = types.SimpleNamespace()
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1089 ns2.x = 1
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1090
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1091 self.assertEqual(types.SimpleNamespace(), types.SimpleNamespace())
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1092 self.assertEqual(ns1, ns2)
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1093 self.assertNotEqual(ns2, types.SimpleNamespace())
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1094
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1095 def test_nested(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1096 ns1 = types.SimpleNamespace(a=1, b=2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1097 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1098 ns3 = types.SimpleNamespace(x=ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1099 ns2.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1100 ns2.ham = '?'
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1101 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1102
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1103 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
1104 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
1105 self.assertEqual(ns2.spam, ns3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1106 self.assertEqual(vars(ns3), dict(x=ns1))
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1107 self.assertEqual(ns3.x.a, 1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1108
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1109 def test_recursive(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1110 ns1 = types.SimpleNamespace(c='cookie')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1111 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1112 ns3 = types.SimpleNamespace(x=1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1113 ns1.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1114 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1115 ns3.spam = ns2
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1116
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1117 self.assertEqual(ns1.spam, ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1118 self.assertEqual(ns1.spam.spam, ns1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1119 self.assertEqual(ns1.spam.spam, ns1.spam)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1120 self.assertEqual(ns2.spam, ns3)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1121 self.assertEqual(ns3.spam, ns2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1122 self.assertEqual(ns2.spam.spam, ns2)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1123
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1124 def test_recursive_repr(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1125 ns1 = types.SimpleNamespace(c='cookie')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1126 ns2 = types.SimpleNamespace()
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1127 ns3 = types.SimpleNamespace(x=1)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1128 ns1.spam = ns1
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1129 ns2.spam = ns3
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1130 ns3.spam = ns2
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1131 name = "namespace"
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1132 repr1 = "{name}(c='cookie', spam={name}(...))".format(name=name)
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1133 repr2 = "{name}(spam={name}(spam={name}(...), x=1))".format(name=name)
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1134
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1135 self.assertEqual(repr(ns1), repr1)
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1136 self.assertEqual(repr(ns2), repr2)
77339
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 def test_as_dict(self):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1139 ns = types.SimpleNamespace(spam='spamspamspam')
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1140
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1141 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1142 len(ns)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1143 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1144 iter(ns)
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1145 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1146 'spam' in ns
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1147 with self.assertRaises(TypeError):
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1148 ns['spam']
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1149
79776
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1150 def test_subclass(self):
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1151 class Spam(types.SimpleNamespace):
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1152 pass
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1153
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1154 spam = Spam(ham=8, eggs=9)
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1155
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1156 self.assertIs(type(spam), Spam)
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1157 self.assertEqual(vars(spam), {'ham': 8, 'eggs': 9})
c5124145e79e Close #16160: Subclass support now works for types.SimpleNamespace. Thanks to RDM for noticing.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79199
diff changeset
1158
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1159 def test_pickle(self):
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1160 ns = types.SimpleNamespace(breakfast="spam", lunch="spam")
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1161
82235
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1162 for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1163 pname = "protocol {}".format(protocol)
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1164 try:
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1165 ns_pickled = pickle.dumps(ns, protocol)
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1166 except TypeError as e:
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1167 raise TypeError(pname) from e
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1168 ns_roundtrip = pickle.loads(ns_pickled)
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1169
82235
e4c065b2db49 Issue #15022: Ensure all pickle protocols are supported.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 82232
diff changeset
1170 self.assertEqual(ns, ns_roundtrip, pname)
82232
3b93ab8c9c20 Issue #15022: Add pickle and comparison support to types.SimpleNamespace.
Eric Snow <ericsnowcurrently@gmail.com>
parents: 79776
diff changeset
1171
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1172
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1173 def test_main():
77339
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1174 run_unittest(TypesTests, MappingProxyTests, ClassCreationTests,
9c445f4695c1 Eric Snow's implementation of PEP 421.
Barry Warsaw <barry@python.org>
parents: 77059
diff changeset
1175 SimpleNamespaceTests)
40450
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1176
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1177 if __name__ == '__main__':
cc992d75d5b3 Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents: 39644
diff changeset
1178 test_main()