From 16c49a97c1e723abcb0eadc833b80a9c37991735 Mon Sep 17 00:00:00 2001 From: cclauss Date: Wed, 28 Jun 2017 06:40:52 +0200 Subject: [PATCH] Make main() a separate function so we can test it --- unittest.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/unittest.py b/unittest.py index 4950921..32a810c 100644 --- a/unittest.py +++ b/unittest.py @@ -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)