import unittest import io import re from unittest import mock import math import student_X as main #Replace student_X with your filename class NumLegalIndicesTests(unittest.TestCase): def test_default_case(self): function = main.num_legal_indices test = False try: incorrect = "" result = function.__doc__.strip() test = incorrect != result except: pass message = "No docstring." self.assertTrue(test, message) inputs = ("", ) test = False correct = 0 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 = ("a", ) test = False correct = 2 if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on a string with a single character." self.assertTrue(test, message) inputs = ("hi", ) test = False correct = 4 if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on a string with two characters." self.assertTrue(test, message) inputs = ("chicken", ) test = False correct = 14 if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = correct == result message = "Doesn't work on a somewhat-long string." self.assertTrue(test, message) if __name__ == "__main__": tests = NumLegalIndicesTests() tests.test_default_case()