import unittest import io import re from unittest import mock import math import student_X as main #Replace student_X with your filename class GetAllBetweenStringTests(unittest.TestCase): def test_default_case(self): function = main.get_all_between_string test = False try: incorrect = "" result = function.__doc__.strip() test = incorrect != result except: pass message = "No docstring." self.assertTrue(test, message) inputs = (6, 7) correct_regex = '6 ?' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = re.match(correct_regex, result) message = "Doesn't work when the parameters are x and x+1." self.assertTrue(test, message) inputs = (6, 8) correct_regex = '6 7 ?' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = re.match(correct_regex, result) message = "Doesn't work when the string should contain two numbers." self.assertTrue(test, message) inputs = (6, 17) correct_regex = '6 7 8 9 10 11 12 13 14 15 16 ?' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = re.match(correct_regex, result) message = "Doesn't work when the string should contain a lot of numbers." self.assertTrue(test, message) inputs = (6, -7) correct_regex = ' ?' if isinstance(inputs, tuple): result = function(*inputs) else: result = function(inputs) test = re.match(correct_regex, result) message = "Doesn't work when the string should contain no numbers. In this case, the string returned shouldn't have contained any numbers." self.assertTrue(test, message) if __name__ == "__main__": tests = GetAllBetweenStringTests() tests.test_default_case()