I have a python script with main, and a whole lot of helper methods. How do I write unit tests for these helper methods which all reside in the same file. A lot of the examples I see online involve creating libraries of helpers and then importing and testing that. In my case it is all one file.
Sample structure:
/user/
|-- pythonscript.py
and I want to write tests for pythonscript.py
.
Sample pythonscript.py
:
def getSum(i ,j):
return i+j
def main():
summer = getSum(1,1)
if __name__ == '__main__':
main()
For example, I want to write tests for methods like getSum
in another file. (I recall there was a tester which would screen .py
files and identify functions needing tests based on appending test_
or _test
, but I cannot seem to find it anymore.)