"""
I'm trying to follow a test driven development paradigm (using
unittest) but can't figure out how to test functions that collect
info from the command line such as the following.
"""
# collect.py
def collect_data():
    ret = {}
    ret['first'] = input("Enter your first name: ")
    ret['last'] = input("Enter your last name: ")
    ret['phone'] = input("Your mobile phone #: ")
    return ret

def main():
    print(collect_data())

if __name__ == "__main__":
    main()

The following works:
$ python3 collect.py < cli_input

# cli_input
Alex
Kleider
415/868-1920

... but I don't know how to make it a unittest.

Thanks in advance for any suggestions.

Alex

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to