#!/usr/bin/python # #Present Working Directory Test Script #By Jonathan Kerr and Julia Bell #Group390 # # import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/") import pexpect, shellio, signal, time, os, re, proc_check #Terminate the Shell def force_shell_termination(shell_process): c.close(force=True) #Get RegEx & Definitions definitions_scriptname = sys.argv[1] def_module = imp.load_source('', definitions_scriptname) logfile = None if hasattr(def_module, 'logfile'): logfile = def_module.logfile #Create the Shell c = pexpect.spawn(def_module.shell, drainpty=True, logfile=logfile) atexit.register(force_shell_termination, shell_process=c) #Set Timeout c.timeout = 5 #Get Current Directory pwd = os.getcwd() #Test Plugin c.sendline("pwd"); assert c.expect_exact(pwd) == 0, "Returned Incorrect Directory"