Use logging instead of print statements.
Setup logging during testing.
Force the user to enter a port during interactive testing.