当前位置: 首页>>代码示例>>Python>>正文


Python Sortings.find_maximum方法代码示例

本文整理汇总了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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:18,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:18,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:19,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:19,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py

示例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)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py


注:本文中的SortingStudy.Sortings.find_maximum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。