test cases for knapsack kp calcprofit takes the required argument profit weight maxweight and returns whether the answer matches to the expected ones returns valueerror for any negative maxweight value return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 maxweight 15 returns valueerror for any negative profit value in the list return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 maxweight 15 returns valueerror for any negative weight value in the list return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 maxweight 15 returns valueerror for any zero maxweight value return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 maxweight null returns indexerror if length of lists profit and weight are unequal return indexerror profit 10 20 30 40 50 weight 2 4 6 8 10 12 maxweight 100 test cases for knapsack kp calc_profit takes the required argument profit weight max_weight and returns whether the answer matches to the expected ones returns valueerror for any negative max_weight value return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 max_weight 15 returns valueerror for any negative profit value in the list return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 max_weight 15 returns valueerror for any negative weight value in the list return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 max_weight 15 returns valueerror for any zero max_weight value return valueerror profit 10 20 30 40 50 60 weight 2 4 6 8 10 12 max_weight null returns indexerror if length of lists profit and weight are unequal return indexerror profit 10 20 30 40 50 weight 2 4 6 8 10 12 max_weight 100
import unittest

import pytest

from knapsack import greedy_knapsack as kp


class TestClass(unittest.TestCase):
    

    def test_sorted(self):
        
        profit = [10, 20, 30, 40, 50, 60]
        weight = [2, 4, 6, 8, 10, 12]
        max_weight = 100
        assert kp.calc_profit(profit, weight, max_weight) == 210

    def test_negative_max_weight(self):
        
        
        
        
        pytest.raises(ValueError, match="max_weight must greater than zero.")

    def test_negative_profit_value(self):
        
        
        
        
        pytest.raises(ValueError, match="Weight can not be negative.")

    def test_negative_weight_value(self):
        
        
        
        
        pytest.raises(ValueError, match="Profit can not be negative.")

    def test_null_max_weight(self):
        
        
        
        
        pytest.raises(ValueError, match="max_weight must greater than zero.")

    def test_unequal_list_length(self):
        
        
        
        
        pytest.raises(IndexError, match="The length of profit and weight must be same.")


if __name__ == "__main__":
    unittest.main()