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


Python Sortings.calculate_total_product方法代码示例

本文整理汇总了Python中SortingStudy.Sortings.calculate_total_product方法的典型用法代码示例。如果您正苦于以下问题:Python Sortings.calculate_total_product方法的具体用法?Python Sortings.calculate_total_product怎么用?Python Sortings.calculate_total_product使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SortingStudy.Sortings的用法示例。


在下文中一共展示了Sortings.calculate_total_product方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_calculate_total_product__if_non_list_value__exception_thrown

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_non_list_value__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with int value
        3. Call calculate_total_product()

        Expected result: Exception thrown
        """
        sortings = Sortings()
        sortings.list = 165

        with self.assertRaises(Exception) as actual:
            sortings.calculate_total_product()

        self.assertEqual("Can not calculate total product for object of type not 'list'", actual.exception.message)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:18,代码来源:SortingStudyTests.py

示例2: test_calculate_total_product__if_list_of_lists_values__exception_thrown

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_list_of_lists_values__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with list of lists
        3. Call calculate_total_product()

        Expected result: Exception thrown
        """
        sortings = Sortings()
        sortings.list = [[-100, -2, 10, -3, 2]]

        with self.assertRaises(Exception) as actual:
            sortings.calculate_total_product()

        self.assertEqual("An input list should contain only numeric values", actual.exception.message)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:18,代码来源:SortingStudyTests.py

示例3: test_calculate_total_product__if_empty_list__exception_thrown

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_empty_list__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list by empty list
        3. Call calculate_total_product()

        Expected result: Exception thrown
        """
        sortings = Sortings()
        sortings.list = []

        with self.assertRaises(Exception) as actual:
            sortings.calculate_total_product()

        self.assertEqual("Can not calculate total product of an empty list", actual.exception.message)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:18,代码来源:SortingStudyTests.py

示例4: test_calculate_total_product__if_one_positive_value__returns_this_value

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_one_positive_value__returns_this_value(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with one positive value
        3. Call calculate_total_product()

        Expected result: This value returned
        """
        sortings = Sortings()
        sortings.list = [11]
        actual_result = sortings.calculate_total_product()
        self.assertEqual(11, actual_result)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:15,代码来源:SortingStudyTests.py

示例5: test_calculate_total_product__if_0_among_values__returns_0

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_0_among_values__returns_0(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with positive values and 0
        3. Call calculate_total_product()

        Expected result: 0 returned
        """
        sortings = Sortings()
        sortings.list = [2, 10, 3, 0]

        actual_result = sortings.calculate_total_product()

        self.assertEqual(0, actual_result)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py

示例6: test_calculate_total_product__if_3_negative_values__returns_negative_product

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__if_3_negative_values__returns_negative_product(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with mix of negative and positive values
        3. Call calculate_total_product()

        Expected result: Correct total returned
        """
        sortings = Sortings()
        sortings.list = [-2, -10, -3]

        actual_result = sortings.calculate_total_product()

        self.assertEqual(-60, actual_result)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py

示例7: test_calculate_total_product__returns_total_product

# 需要导入模块: from SortingStudy import Sortings [as 别名]
# 或者: from SortingStudy.Sortings import calculate_total_product [as 别名]
    def test_calculate_total_product__returns_total_product(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with int values
        3. Call calculate_total_product()

        Expected result: Correct value of total product returned
        """
        sortings = Sortings()
        sortings.list = [444, 1, 2, 3]

        actual_result = sortings.calculate_total_product()

        self.assertEqual(2664, actual_result)
开发者ID:VarvaraKorol,项目名称:Playground,代码行数:17,代码来源:SortingStudyTests.py


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