本文整理汇总了Python中SortingStudy.Sortings.find_maximum方法的典型用法代码示例。如果您正苦于以下问题:Python Sortings.find_maximum方法的具体用法?Python Sortings.find_maximum怎么用?Python Sortings.find_maximum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortingStudy.Sortings
的用法示例。
在下文中一共展示了Sortings.find_maximum方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_maximum__if_non_list_value__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test_find_maximum__if_non_list_value__exception_thrown(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with float value
3. Call find_maximum()
Expected result: Exception thrown
"""
sortings = Sortings()
sortings.list = 20.12
with self.assertRaises(Exception) as actual:
sortings.find_maximum()
self.assertEqual("Can not find maximum for object of type not 'list'", actual.exception.message)
示例2: test_find_maximum__if_list_of_lists__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test_find_maximum__if_list_of_lists__exception_thrown(self):
"""
Scenario:
1. Create object of class Sortings
2. Initialize list by list of two lists
3. Call find_maximum()
Expected result: Exception thrown
"""
sorting = Sortings()
sorting.list = [[1, 3, 4, 5, 0], [1, 2, 4, 6, 0, 9]]
with self.assertRaises(Exception) as actual:
sorting.find_maximum()
self.assertEqual("An input list should contain only numeric values", actual.exception.message)
示例3: test__find_maximum__if_none__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_none__exception_thrown(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with None
3. Call find_maximum()
Expected result: Exception is thrown
"""
sortings = Sortings()
sortings.list = None
with self.assertRaises(Exception) as actual:
sortings.find_maximum()
self.assertEqual("Can not find maximum in a list 'None'", actual.exception.message)
示例4: test__find_maximum__if_empty_list__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_empty_list__exception_thrown(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with an empty list
3. Call find_maximum()
Expected result: Exception is thrown
"""
sortings = Sortings()
sortings.list = []
with self.assertRaises(Exception) as exc:
sortings.find_maximum()
self.assertEqual("Can not find maximum in an empty list", exc.exception.message)
示例5: test__find_maximum__if_all_values_are_identical__returns_one_value
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_all_values_are_identical__returns_one_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with equal values
3. Call find_maximum()
Expected result: Single initialized value returned
"""
sortings = Sortings()
sortings.list = [2, 2, 2, 2, 2, 2]
actual_result = sortings.find_maximum()
self.assertEqual(2, actual_result)
示例6: test__find_maximum__if_one_value__returns_this_value
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_one_value__returns_this_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with single value
3. Call find_maximum()
Expected result: This value is returned
"""
sortings = Sortings()
sortings.list = [0]
actual_result = sortings.find_maximum()
self.assertEqual(0, actual_result)
示例7: test__find_maximum__if_float_values__returns_maximum
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_float_values__returns_maximum(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with float values
3. Call find_minimum()
Expected result: The minimal value returned
"""
sortings = Sortings()
sortings.list = [0.333, 0, 1 / 3, 1.0 / 3.0]
actual_result = sortings.find_maximum()
self.assertEqual(1.0 / 3.0, actual_result)
示例8: test__find_maximum__if_negative_values__returns_maximum
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_maximum [as 别名]
def test__find_maximum__if_negative_values__returns_maximum(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with negative values
3. Call find_maximum()
Expected result: Maximum value returned
"""
sortings = Sortings()
sortings.list = [-2, 2, -1, 0]
actual_result = sortings.find_maximum()
self.assertEqual(2, actual_result)