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

This will enable us to use [pytest](https://docs.pytest.org) to do end-to-end tests like:
https://github.com/LazoCoder/Pokemon-Terminal/pull/60/files#diff-1532f81ff7af5d26a72ae57cdbeabb53R19
This commit is contained in:
cclauss 2017-06-29 09:00:39 +02:00 committed by GitHub
parent 16c49a97c1
commit 9c5b040571

View file

@ -2,7 +2,6 @@
# The main module that brings everything together.
from sys import argv
from database import Database
import random
import scripter
@ -265,7 +264,7 @@ def single_argument_handler(arg):
change_terminal_background(db, arg)
if __name__ == "__main__":
def main(argv):
# Entrance to the program.
if len(argv) == 1:
print('No command line arguments specified.'
@ -278,3 +277,8 @@ if __name__ == "__main__":
else:
print('Invalid number of arguments.'
'\nType "help" to see all the commands.')
if __name__ == "__main__":
# Entrance to the program.
main(sys.argv)