當前位置: 首頁>>代碼示例>>Python>>正文


Python Sortings.calculate_total方法代碼示例

本文整理匯總了Python中SortingStudy.Sortings.calculate_total方法的典型用法代碼示例。如果您正苦於以下問題:Python Sortings.calculate_total方法的具體用法?Python Sortings.calculate_total怎麽用?Python Sortings.calculate_total使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SortingStudy.Sortings的用法示例。


在下文中一共展示了Sortings.calculate_total方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_calculate_total__if_string_values__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__if_string_values__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with string
        3. Call calculate_total()

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

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

        self.assertEqual("An input list should contain only numeric values", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:18,代碼來源:SortingStudyTests.py

示例2: test_calculate_total__if_non_list_value__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__if_non_list_value__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with int value
        3. Call calculate_total()

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

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

        self.assertEqual("Can not calculate total for object of type not 'list'", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:18,代碼來源:SortingStudyTests.py

示例3: test_calculate_total__if_empty_list__exception_thrown

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__if_empty_list__exception_thrown(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list by empty list
        3. Call calculate_total()

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

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

        self.assertEqual("Can not calculate total of an empty list", actual.exception.message)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:18,代碼來源:SortingStudyTests.py

示例4: test_calculate_total__if_one_negative_value__returns_this_value

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__if_one_negative_value__returns_this_value(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with one negative value
        3. Call calculate_total()

        Expected result: This value returned
        """
        sortings = Sortings()
        sortings.list = [-33012]
        actual_result = sortings.calculate_total()
        self.assertEqual(-33012, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:15,代碼來源:SortingStudyTests.py

示例5: test__calculate_total__if_float_values__returns_total

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test__calculate_total__if_float_values__returns_total(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with float values and float resulting expressions
        3. Call calculate_total()

        Expected result: Correct total returned
        """
        sortings = Sortings()
        sortings.list = [0.333, 0, 1 / 3, 1.0 / 3.0]

        actual_result = sortings.calculate_total()

        self.assertEqual(0.6663333333333333, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py

示例6: test_calculate_total__if_negative_values__returns_total

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__if_negative_values__returns_total(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with mix of negative and positive values
        3. Call calculate_total()

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

        actual_result = sortings.calculate_total()

        self.assertEqual(87, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py

示例7: test_calculate_total__total_is_calculated

# 需要導入模塊: from SortingStudy import Sortings [as 別名]
# 或者: from SortingStudy.Sortings import calculate_total [as 別名]
    def test_calculate_total__total_is_calculated(self):
        """
        Scenario:
        1. Create object of Sortings class
        2. Initialize list with int values
        3. Call calculate_total()

        Expected result: Total of int values returned
        """
        sortings = Sortings()
        sortings.list = [20202, 1, 2, 3]

        actual_result = sortings.calculate_total()

        self.assertEqual(20208, actual_result)
開發者ID:VarvaraKorol,項目名稱:Playground,代碼行數:17,代碼來源:SortingStudyTests.py


注:本文中的SortingStudy.Sortings.calculate_total方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。