This question already has an answer here:
- python mocking raw input in unittests 5 answers
I have a python script which has a main function like this:
if __name__ == '__main__':
root_dir = input("Enter root directory: ") #NEED TO ENTER FULL PWD PATH
keyword = input("Enter regular expression: ")
logging.basicConfig(filename='errors.log')
directory_count = count_match()
How can I write test cases if the script requires user input? In this case, I'd like to write test cases checking to see if the two user inputs are valid. First, is it a valid directory, and second if it is a valid reg ex.
Aucun commentaire:
Enregistrer un commentaire