I have a file to validate the label
#configmanager.py
class FunctionNode(object):
def __validate_func_label(self, func_label):
pattern = re.compile('^fn[1-9][0-9]{0,1}$')
if not pattern.match(func_label):
raise Exception(
f"Invalid value {func_label} for function label in function config.")
and I have to write a test case for it using Unit Testing. Test case will check if user enters fn
is between 1 and 99, it will pass. Otherwise if fn
out of range such as fn0
or fn100
then it fail. I writed a TestClass
#test__validate_func_label.py
import unittest
from configmanager import FunctionNode
class TestValidateFuncLabel(unittest.TestCase):
def setUp(self):
pass
def test_fn_within_range(self):
for i in range(1,99):
self.assertEqual(fn(i),output[i])
if __name__ == "__main__":
unittest.main()
But I feel like I'm not on the right track.
Is there any way i can assert fn
is within range from 1 to 99?
Any help is appreciated.