import unittest import io import re from unittest import mock import math import student_X as main #Replace student_X with your filename class CapsuleVolumeTests(unittest.TestCase): def test_default_case(self): function = main.capsule_volume try: docstring = function.__doc__ docstring = docstring.strip() except: docstring = "" correct = docstring != "" message = "No docstring." self.assertTrue(correct, message) test = False try: radius = 15 capsule_length = 35 incorrect = 38877.20908817369 result = function(radius, capsule_length) test = not (incorrect-.01 <= result <= incorrect+.01) except: pass message = "I think you have a formula (maybe from online) but aren't using it correctly. Are you using the whole capsule length only as the length of your capsule's middle section?" self.assertTrue(test, message) test = False try: radius = 15 capsule_length = 35 correct = 17671.45867 result = function(radius, capsule_length) test = correct-.01 <= result <= correct+.01 except: pass message = "Doesn't return the correct size of a capsule with a short middle section." self.assertTrue(test, message) if __name__ == "__main__": tests = CapsuleVolumeTests() tests.test_default_case()