#!/usr/bin/python # # Test the fantasy football calculator by running tests on the various positions with various stat lines # run by typing fantasy folowed by a position (QB WR RB, or TE) and then followed by a stat line with is yards touchdowns and turnovers # # import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/"); import pexpect, shellio, signal, time, os, re, proc_check #Ensure the shell process is terminated def force_shell_termination(shell_process): c.close(force=True) #pulling in the regular expression and other definitions definitions_scriptname = sys.argv[1] def_module = imp.load_source('', definitions_scriptname) logfile = None if hasattr(def_module, 'logfile'): logfile = def_module.logfile # spawn an instance of bash. PS1 is the env variable from which bash # draws its prompt c = pexpect.spawn(def_module.shell, drainpty=True, logfile=logfile) atexit.register(force_shell_termination, shell_process=c) # set timeout for all following 'expect*' calls to 2 seconds c.timeout = 2 #checks to makes sure the points are calculated correctly for a QB c.sendline("fantasy QB 100 4 2") assert c.expect_exact(def_module.prompt) == 0, "QB 16" #checks to make sure points are calculated correclty for a RB c.sendline("fantasy RB 150 1 0") assert c.expect_exact(def_module.prompt) == 0, "RB 21" #checks to make sure points are calculated correclty for a WR c.sendline("fantasy WR 70 2 0") assert c.expect_exact(def_module.prompt) == 0, "WR 19" #checks to make sure points are calculated correclty for a TE c.sendline("fantasy TE 20 1 0") assert c.expect_exact(def_module.prompt) == 0, "TE 8" shellio.success()