Make main() a separate function so we can test it

This commit is contained in:
cclauss 2017-06-28 06:40:52 +02:00 committed by GitHub
parent b32ed4b9e2
commit 16c49a97c1

View file

@ -1,7 +1,7 @@
# This module is for testing the different components of this project.
from database import Database
from sys import argv
import sys
def print_items(items):
@ -70,7 +70,7 @@ def test_database_double_arg(arg):
print("No such public method '" + arg + "' with two parameters exists in the Database class.")
if __name__ == "__main__":
def main(argv):
if len(argv) == 1:
print("No command line parameters provided.")
elif len(argv) == 2:
@ -79,3 +79,7 @@ if __name__ == "__main__":
test_database_double_arg(argv)
else:
print("This module only takes one command line parameter.")
if __name__ == "__main__":
main(sys.argv)