def main(args): prevDir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) currentDir = args.directory testFile = args.testFile if currentDir == None: currentDir = prevDir if testFile == None: testFile = os.path.join(currentDir, "Test.py") downloadsFolder, reportsFolder = setupFilesAndFolders(prevDir, currentDir) gmail = GmailCommunication(args) if args.alreadyExistingModules: modules = [] for f in os.listdir(currentDir): pathToFile = os.path.join(currentDir,f) head, extension = os.path.splitext(pathToFile) if os.path.isfile(pathToFile) and extension == ".py" \ and f != "conftest.py" and not f.lower().startswith("test"): modules.append(pathToFile) print modules for module in modules: moduleName = os.path.splitext(os.path.split(module)[1])[0] reportFile = os.path.join(reportsFolder, moduleName + ".html") print testFile, module, reportFile t = TestWrapper(testFile, module, reportFile) t.runTests() oldMessages = [] while True: print "Recibiendo mensajes" messages = gmail.getMessages() for m in messages: if m['id'] not in oldMessages: message = gmail.getMessage(m['id']) msgFromMail = gmail.getHeaderFrom(message) msgFromName = gmail.getStudentByMail(msgFromMail) msgAttachment = gmail.getAttachments(message, downloadsFolder, msgFromName) reportFile = os.path.join(reportsFolder, msgFromName + ".html") if msgAttachment != "": t = TestWrapper(testFile, msgAttachment, reportFile) t.runTests() gmail.createAndSendMessage(msgFromMail, reportsFolder, msgFromName + ".html") oldMessages.append(m['id']) time.sleep(60)
import os,sys,inspect currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) parentdir = os.path.dirname(currentdir) sys.path.insert(0,parentdir) from TestWrapper import TestWrapper # for i in range(3): # params = "testPy.py --timeout=10 --libname=m" + str(i+1) # pytest.main(params) testPath = "/home/juanjo/Proyectos/PythonAuxiliar/Examples/testPy.py" modulePathTemplate = "/home/juanjo/Proyectos/PythonAuxiliar/Examples/m" reportPathTemplate = "/home/juanjo/Proyectos/PythonAuxiliar/Examples/Reports/m" for i in range(1,4): t = TestWrapper(testPath, modulePathTemplate + str(i) + ".py", reportPathTemplate + str(i) + ".html") t.runTests() # moduleName = "/home/juanjo/Proyectos/Auxiliar/m1.py" # reportFile = "/home/juanjo/Proyectos/Auxiliar/Reports/yo.html" # t = TestWrapper(testPath, moduleName, reportFile) # t.runTests()