import unittest
import io
import re
from unittest import mock
import math
import student_X as main #Replace student_X with your filename 
import sys
import io
from io import StringIO
import inspect
    
    
    
 

class WholesaleCostTests(unittest.TestCase):
    
    def test_default_case(self):
        function = main.wholesale_cost
        
        with mock.patch('sys.stdout', new=io.StringIO()) as fake_stdout:
            function()

        output = fake_stdout.getvalue().strip()
        source_code = inspect.getsource(function)
        
        
        correct = "cover_price = 24.95" in source_code and "discount = .4" in source_code and "first_copy_shipping_cost = 3" in source_code and "shipping_cost_per_copy = .75" in source_code and "num_copies = 60" in source_code
        message = "It looks like you modified the variable-setting lines."
        self.assertTrue(correct, message)
        
        
        correct = source_code.count('cover_price') >= 2
        message = "I want you to use the variables, including cover_price."
        self.assertTrue(correct, message)
        
        
        correct = source_code.count('discount') >= 2
        message = "I want you to use the variables, including discount."
        self.assertTrue(correct, message)
        
        
        correct = source_code.count('first_copy_shipping_cost') >= 2
        message = "I want you to use the variables, including first_copy_shipping_cost."
        self.assertTrue(correct, message)
        
        
        correct = source_code.count('shipping_cost_per_copy') >= 2
        message = "I want you to use the variables, including shipping_cost_per_copy."
        self.assertTrue(correct, message)
        
        
        correct = source_code.count('num_copies') >= 2
        message = "I want you to use the variables, including num_copies."
        self.assertTrue(correct, message)
        
        
        correct = not "646.0" in output 
        message = "A 40 percent discount does not mean that the price is .4 times the full price..."
        self.assertTrue(correct, message)
        
        
        correct = "945.4" in output 
        message = "You're not printing the correct cost."
        self.assertTrue(correct, message)

        
        
if __name__ == "__main__":
    tests = WholesaleCostTests()
    tests.test_default_case()