import unittest import io import re from unittest import mock import math import student_X as main #Replace student_X with your filename class IndexStatusTests(unittest.TestCase): def test_default_case(self): function = main.index_status test = False try: incorrect = "" result = function.__doc__.strip() test = incorrect != result except: pass message = "No docstring." self.assertTrue(test, message) inputs = ("", 1) test = False correct = 'too high' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on the empty string." self.assertTrue(test, message) inputs = ("", -1) test = False correct = 'too low' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on the empty string." self.assertTrue(test, message) inputs = ("", 0) test = False correct = 'too high' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on the empty string when the index is zero." self.assertTrue(test, message) inputs = ("chicken", 2) test = False correct = 'i' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is in the middle of the string." self.assertTrue(test, message) inputs = ("chicken", 107) test = False correct = 'too high' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is too high." self.assertTrue(test, message) inputs = ("chicken", -107) test = False correct = 'too low' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is too low." self.assertTrue(test, message) inputs = ("chicken", 6) test = False correct = 'n' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is in the string." self.assertTrue(test, message) inputs = ("chicken", 0) test = False correct = 'c' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is in the string." self.assertTrue(test, message) inputs = ("chicken", -7) test = False correct = 'c' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on negative indices in the string." self.assertTrue(test, message) inputs = ("chicken", -8) test = False correct = 'too low' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is too low." self.assertTrue(test, message) inputs = ("chicken", 7) test = False correct = 'too high' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work when the index is too high." self.assertTrue(test, message) if __name__ == "__main__": tests = IndexStatusTests() tests.test_default_case()