示例#1
0
 def test_with_non_lists(self):
     self.assertIterableEqual(minmax((89, 17, 70, 9)), (9, 89))
     self.assertIterableEqual(minmax({8, 7, 5, 3, 9, 6, 2}), (2, 9))
     self.assertIterableEqual(minmax(n**2 for n in range(1, 4)), (1, 9))
     with self.assertRaises(ValueError):
         minmax(iter([]))
示例#2
0
 def test_very_large_numbers(self):
     self.assertIterableEqual(
         minmax([2**1000, -2**1000]),
         (-2**1000, 2**1000),
     )
示例#3
0
 def test_error_on_empty_iterable(self):
     with self.assertRaises(ValueError):
         minmax([])
示例#4
0
 def test_strings(self):
     words = ["alfalfa", "animal", "apple", "acoustic", "axiom"]
     self.assertIterableEqual(minmax(words), ("acoustic", "axiom"))
示例#5
0
 def test_mixed_types(self):
     with self.assertRaises(TypeError):
         minmax(['a', 2])
示例#6
0
 def test_negative_numbers(self):
     self.assertIterableEqual(minmax([-10, -8, -7, -5, -3]), (-10, -3))
示例#7
0
 def test_same_item_multiple_times(self):
     self.assertIterableEqual(minmax([8, 8, 8]), (8, 8))
     self.assertIterableEqual(minmax([7, 5, 6, 5, 7]), (5, 7))
示例#8
0
 def test_single_item(self):
     self.assertIterableEqual(minmax([10]), (10, 10))
示例#9
0
 def test_with_out_of_order_numbers(self):
     self.assertIterableEqual(minmax([10, 8, 7, 5.0, 3, 6, 2]), (2, 10))
示例#10
0
 def test_ordered_numbers(self):
     self.assertIterableEqual(minmax([0, 1, 2, 3, 4]), (0, 4))