本文整理汇总了Python中SortingStudy.Sortings.find_minimum方法的典型用法代码示例。如果您正苦于以下问题:Python Sortings.find_minimum方法的具体用法?Python Sortings.find_minimum怎么用?Python Sortings.find_minimum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortingStudy.Sortings
的用法示例。
在下文中一共展示了Sortings.find_minimum方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_find_minimum__if_non_list_value__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__if_non_list_value__exception_thrown(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with int value
3. Call find_minimum()
Expected result: Exception thrown
"""
sortings = Sortings()
sortings.list = -20303
with self.assertRaises(Exception) as actual:
sortings.find_minimum()
self.assertEqual("Can not find min_val for object of type not 'list'", actual.exception.message)
示例2: test_find_minimum__if_list_of_lists__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__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_minimum()
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_minimum()
self.assertEqual("An input list should contain only numeric values", actual.exception.message)
示例3: test_find_minimum__if_None__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__if_None__exception_thrown(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with None
3. Call find_minimum()
Expected result: Exception is thrown
"""
sortings = Sortings()
sortings.list = None
with self.assertRaises(Exception) as actual:
sortings.find_minimum()
self.assertEqual("Can not find min_val in a list 'None'", actual.exception.message)
示例4: test_find_minimum__if_empty_list__exception_thrown
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__if_empty_list__exception_thrown(self):
"""
Scenario:
1. Create object of class Sortings
2. Initialize list with an empty list
3. Call find_minimum()
Expected result: Exception thrown
"""
sorting = Sortings()
sorting.list = []
with self.assertRaises(Exception) as actual:
sorting.find_minimum()
self.assertEqual("Can not find min_val in an empty list", actual.exception.message)
示例5: test__find_minimum__if_float_values__returns_minimum
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test__find_minimum__if_float_values__returns_minimum(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_minimum()
self.assertEqual(0, actual_result)
示例6: test__find_minimum__if_negative_values__returns_minimum
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test__find_minimum__if_negative_values__returns_minimum(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with negative values
3. Call find_minimum()
Expected result: The minimal negative value returned
"""
sortings = Sortings()
sortings.list = [-2, 2, -1, 0]
actual_result = sortings.find_minimum()
self.assertEqual(-2, actual_result)
示例7: test_find_minimum__if_equal_values__returns_one_value
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__if_equal_values__returns_one_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with equal values
3. Call find_minimum()
Expected result: Single initialized value returned
"""
sortings = Sortings()
sortings.list = [2, 2, 2, 2, 2, 2]
actual_result = sortings.find_minimum()
self.assertEqual(2, actual_result)
示例8: test_find_minimum__if_one_value__returns_this_value
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__if_one_value__returns_this_value(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with single value
3. Call find_minimum()
Expected result: This value is returned
"""
sortings = Sortings()
sortings.list = [34566]
actual_result = sortings.find_minimum()
self.assertEqual(34566, actual_result)
示例9: test_find_minimum__two_times__returns_minimal
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__two_times__returns_minimal(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with positive integers
3. Call find_minimum() method
4. Initialize list with other positive integers
5. Call find_minimum() method
Expected result: A correct minimum value returned both times.
"""
sortings = Sortings()
sortings.list = [5, 1, 2, 3]
actual_result = sortings.find_minimum()
self.assertEqual(1, actual_result)
sortings.list = [3456, 123, 12, 35]
actual_result = sortings.find_minimum()
self.assertEqual(12, actual_result)
示例10: test_find_minimum__returns_minimal
# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import find_minimum [as 别名]
def test_find_minimum__returns_minimal(self):
"""
Scenario:
1. Create object of Sortings class
2. Initialize list with positive integers
3. Call find_minimum()
Expected result: A correct minimum value returned
"""
sortings = Sortings()
sortings.list = [5, 1, 2, 3]
actual_result = sortings.find_minimum()
self.assertEqual(1, actual_result)