OLD | NEW |
1 # test interactions between int, float, Decimal and Fraction | 1 # test interactions between int, float, Decimal and Fraction |
2 | 2 |
3 import unittest | 3 import unittest |
4 import random | 4 import random |
5 import math | 5 import math |
6 import sys | 6 import sys |
7 import operator | 7 import operator |
8 from test.support import run_unittest | 8 from test.support import run_unittest |
9 | 9 |
10 from decimal import Decimal as D | 10 from decimal import Decimal as D |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 x = {'halibut', HalibutProxy()} | 143 x = {'halibut', HalibutProxy()} |
144 self.assertEqual(len(x), 1) | 144 self.assertEqual(len(x), 1) |
145 | 145 |
146 class ComparisonTest(unittest.TestCase): | 146 class ComparisonTest(unittest.TestCase): |
147 def test_mixed_comparisons(self): | 147 def test_mixed_comparisons(self): |
148 | 148 |
149 # ordered list of distinct test values of various types: | 149 # ordered list of distinct test values of various types: |
150 # int, float, Fraction, Decimal | 150 # int, float, Fraction, Decimal |
151 test_values = [ | 151 test_values = [ |
152 float('-inf'), | 152 float('-inf'), |
153 D('-1e999999999'), | 153 D('-1e425000000'), |
154 -1e308, | 154 -1e308, |
155 F(-22, 7), | 155 F(-22, 7), |
156 -3.14, | 156 -3.14, |
157 -2, | 157 -2, |
158 0.0, | 158 0.0, |
159 1e-320, | 159 1e-320, |
160 True, | 160 True, |
161 F('1.2'), | 161 F('1.2'), |
162 D('1.3'), | 162 D('1.3'), |
163 float('1.4'), | 163 float('1.4'), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 for op in operator.le, operator.lt, operator.ge, operator.gt: | 197 for op in operator.le, operator.lt, operator.ge, operator.gt: |
198 self.assertRaises(TypeError, op, z, v) | 198 self.assertRaises(TypeError, op, z, v) |
199 self.assertRaises(TypeError, op, v, z) | 199 self.assertRaises(TypeError, op, v, z) |
200 | 200 |
201 | 201 |
202 def test_main(): | 202 def test_main(): |
203 run_unittest(HashTest, ComparisonTest) | 203 run_unittest(HashTest, ComparisonTest) |
204 | 204 |
205 if __name__ == '__main__': | 205 if __name__ == '__main__': |
206 test_main() | 206 test_main() |
OLD | NEW |