def test_update_table( self): # testing if we have have not entered path to data data = ["./test_data/test4.xlsx", "-upd"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual(cm.exception.code, 'Data successfully updated')
def test_two_flags(self): data = ["./test_data/test1.xlsx", "-c", "-upd"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual( cm.exception.code, 'Please, select only ONE of the flag arguments: create or update')
def test_create_table( self): # testing if we have have not entered path to data data = ["./test_data/test3.xlsx", "-c"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual(cm.exception.code, 'Table created successfully and filled with data')
def test_file_does_not_exist( self): # testing invalid file exception found error data = ["./file_does_not_exist.xlsx"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual( cm.exception.code, 'Error FileNotFound: Enter file path carefully once more')
def test_file_not_found( self): # testing invalid file exception openpyxl error data = ["./invalid_file.xl"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual( cm.exception.code, 'Error InvalidFileException: Enter file path carefully once more')
def test_help(self): # testing argparse --help systemexit == 0 and all ok data = ["-h"] # output suppressed sys.stdout = io.StringIO() with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) sys.stdout = sys.__stdout__ self.assertEqual(cm.exception.code, 0)
def test_empty_data( self): # testing if we have have not entered path to data data = ["./test_data/test2.xlsx", "-c"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual( cm.exception.code, 'Table given is empty. Add some lines and try again.')
def test_no_args( self): # testing with no arguments, argparse systemexit error == 2 # redirect error outputs of argparse lib to nowhere, they are catched, that's ok. sys.stderr = io.StringIO() data = [] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) sys.stderr = sys.__stderr__ self.assertEqual(cm.exception.code, 2)
def test1(self): outFH = tempfile.TemporaryFile() source = "tests/1.xml" target = "tests/2-target.xml" alignment = "tests/2-align.xml" annotations = "tests/2-sentiment.ptb" project.main(source, annotations, alignment, target, outFH, True, False, False, ['good', 'fuzzy']) outFH.seek(0) #self.compareXML("tests/2-mapped.xml", outFH) #this only compares node ids! #self.compareTrees("tests/2-mapped.xml", outFH) self.compareSentences("tests/2-mapped.xml", outFH)
def test_project(inputs, main_ret): input_values = inputs output = [] def mock_input(s): print(s) output.append(s) print(input_values[0]) return input_values.pop(0) project.input = mock_input ret_val = project.main() assert ret_val == main_ret
def testRootProjection(self): """This test tests the root projection. Root labels are projected from source to target if the target root does not have a valid sentiment label. """ outFH = tempfile.TemporaryFile() source = "tests/1.xml" target = "tests/2-target.xml" alignment = "tests/3-align.xml" annotations = "tests/2-sentiment.ptb" project.main(source, annotations, alignment, target, outFH, True, False, True, ['good', 'fuzzy']) outFH.seek(0) #self.compareXML("tests/2-mapped.xml", outFH) #this only compares node ids! #self.compareTrees("tests/2-mapped.xml", outFH) self.compareSentences("tests/3-mapped.xml", outFH)
def speech_work(): global lan1 global lan2 print(lan1,lan2) print(dic[lan1],dic[lan2]) ans1,ans2=pu.main(dic[lan1],dic[lan2]) translator= Translator(from_lang=dic[lan2],to_lang=dic[lan1]) ans1 = translator.translate(ans2) #print(ans1+" kk") l6=tk.Label(mw3,text="",bg='deepskyblue2') l6.config(height=10,width=500) l6.place(x=150,y=320) l4=tk.Label(mw3,text=ans1,font=('Helvetica',20),bg='plum3') l4.place(x=150,y=320) l5=tk.Label(mw3,text=ans2,font=('Helvetica',20),bg='plum3') l5.place(x=150,y=370) print(ans1,ans2)
def main_pro(self): reload(project) project.main() self.file_open()
for mode in modes: for threshold in thresholds: if (mode == "intrain" and threshold == 0): continue print( "\n\n=================== * === * === * ======================" ) print("Calling with: " + arch + " " + str(threshold) + " " + algo + " " + mode + "\n") # INCASE OF POSTTRAIN, we don't need to train the model over and over again: if (not (mode == 'posttrain' and threshold != 0)): modelCopy = copy.deepcopy(model) TrainingAccuracies, sparselevel, testaccuracy = project.main( modelCopy, algo, mode, threshold) print( "====================== * === * === * =======================\n\n" ) results.save(arch, algo, mode, threshold, sparselevel, testaccuracy, TrainingAccuracies) f = open('outputData.json', 'w') f.write(str(results.resultsData)) f.close() pickle.dump(results.resultsData, open('outputPickleData.p', "wb"))
def index(): global firstTime if firstTime: print(model_firsttime.main()) firstTime = False return render_template('index.html')
import project if __name__ == '__main__': project.main()
from project import main if __name__ == '__main__': main()
from imgtec.console import * import imgtec.codescape from imgtec.test import * import project @test.suiteSetUp def suiteSetUp(): project.start() @test.suiteTearDown def suiteTearDown(): project.stop() @test def test0(): res = project.load() devs = res["targets"] go(quiet, devices=devs) project.waitforhalt(1800, all, probe().socs[0]) if regs("a0") != 0: fail() if imgtec.codescape.environment == "standalone": sys.exit(project.main()) else: project.load(rsts, ldrs)
import project as project with open("num_tests.txt", "r") as file: number = int(file.readline()) for i in range(number): arrival_name = "arrival_" + str(i + 1) + ".txt" service_name = "service_" + str(i + 1) + ".txt" para_name = "para_" + str(i + 1) + ".txt" mode_name = "mode_" + str(i + 1) + ".txt" project.main(arrival_name, service_name, para_name, mode_name, i + 1)
def test_no_action(self): data = ["./test_data/test1.xlsx"] with self.assertRaises(SystemExit) as cm: args = self.parser.parse_args(data) project.main(args) self.assertEqual(cm.exception.code, 'No action specified')
def setUp(self): from project import main app = main({}) from webtest import TestApp self.testapp = TestApp(app)
#!/usr/bin/env python3 from wsgiref.simple_server import make_server from pyramid.config import Configurator from project import main if __name__ == '__main__': port = 8080 server = make_server('0.0.0.0', port, main()) print('will now serve on port ', port) server.serve_forever()