def testGetEmptyStorage(self): TestSuite.setServerObjects({}) expected = { "objects" : [] } response = TestSuite.client.get(INDEX_ROUTE) self.assertEquals(json.loads(response.data), expected)
def testGetEmptyStorage(self): TestSuite.setServerObjects({}) expected = {"objects": []} response = TestSuite.client.get(INDEX_ROUTE) self.assertEquals(json.loads(response.data), expected)
def testGetSingleObject(self): TestSuite.setServerObjects({"uid00112233": {"FieldOne" : "One", "Field2" : 2, "uid" : "uid00112233"}}) expected = { "objects" : [{"url" : "http://localhost/api/objects/uid00112233"}] } response = TestSuite.client.get(INDEX_ROUTE) self.assertEquals(json.loads(response.data), expected)
def testPostMultipleObjects(self): TestSuite.setServerObjects({}) postObject = [{ "field1": "data1", "field two": 2 }, { "field3": "data3", "field four": 4 }] response = TestSuite.client.post(INDEX_ROUTE, data=json.dumps(postObject), content_type='application/json') responseObject = json.loads(response.data) # Check that a list of objects is returned with the correct number of entries self.assertTrue(isinstance(responseObject["objects"], list)) self.assertEquals(len(responseObject["objects"]), len(postObject)) # Check that each has a uid and that the uid is present in the server's stored objects for item in responseObject["objects"]: self.assertTrue("uid" in item) self.assertTrue(item["uid"] in TestSuite.getServerObjects())
def testGetRealUid(self): expected = {"FieldOne" : "One", "Field2" : 2, "uid" : "uid00112233"} TestSuite.setServerObjects({"uid00112233" : expected}) response = TestSuite.client.get(INDEX_ROUTE + "uid00112233") self.assertEquals(json.loads(response.data), expected)
def testDeleteRealUid(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) response = TestSuite.client.delete(INDEX_ROUTE + uid) self.assertFalse(response.data) self.assertEquals(len(TestSuite.getServerObjects()), 0)
def testGetWrongUid(self): TestSuite.setServerObjects({}) expected = { "message": "404: Not Found", "url": "http://localhost/api/objects/uid00112233", "verb": "GET" } response = TestSuite.client.get(INDEX_ROUTE + "uid00112233") self.assertEquals(json.loads(response.data), expected)
def testPostEmptyRequest(self): TestSuite.setServerObjects({}); expected = { "message": "400: Bad Request", "url": "http://localhost/api/objects/", "verb": "POST" } response = TestSuite.client.post(INDEX_ROUTE, content_type = 'application/json') self.assertEquals(json.loads(response.data), expected)
def testDelete(self): TestSuite.setServerObjects({}); expected = { "message": "405: Method Not Allowed", "url": "http://localhost/api/objects/", "verb": "DELETE" } response = TestSuite.client.delete(INDEX_ROUTE, content_type = 'application/json') self.assertEquals(json.loads(response.data), expected)
def testDelete(self): TestSuite.setServerObjects({}) expected = { "message": "405: Method Not Allowed", "url": "http://localhost/api/objects/", "verb": "DELETE" } response = TestSuite.client.delete(INDEX_ROUTE, content_type='application/json') self.assertEquals(json.loads(response.data), expected)
def testPostEmptyRequest(self): TestSuite.setServerObjects({}) expected = { "message": "400: Bad Request", "url": "http://localhost/api/objects/", "verb": "POST" } response = TestSuite.client.post(INDEX_ROUTE, content_type='application/json') self.assertEquals(json.loads(response.data), expected)
def testPutRealUid(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) putObject = {"FieldThree" : "Three", "Field4" : 4, "uid" : uid} response = TestSuite.client.put(INDEX_ROUTE + uid, data = json.dumps(putObject), content_type = 'application/json') self.assertTrue(uid in TestSuite.getServerObjects()) self.assertEquals(TestSuite.getServerObjects()[uid], putObject) self.assertEquals(len(TestSuite.getServerObjects()), 1) self.assertEquals(json.loads(response.data), putObject)
def Test(**attrs): import sys, os import TestSuite, Errors if not attrs.has_key('script_name'): attrs['script_name'] = sys.argv[0] if not attrs.has_key('script_args'): attrs['script_args'] = sys.argv[1:] # Create the TestSuite instance using the arguments to initialize it. test_dir = os.path.dirname(attrs['script_name']) or os.getcwd() try: sys.path.insert(0, test_dir) try: suite = TestSuite.TestSuite(attrs) except Errors.TestSuiteSetupError, msg: if attrs.has_key('name'): raise SystemExit, \ 'error in %s test command: %s' % (attrs['name'], msg) else: raise SystemExit, \ 'error in test command: %s' % msg try: ok = suite.parseCommandLine() except Errors.TestSuiteArgumentError, msg: raise SystemExit, \ suite.generateUsage() + '\nerror: %s' % msg
def testGetSingleObject(self): TestSuite.setServerObjects({ "uid00112233": { "FieldOne": "One", "Field2": 2, "uid": "uid00112233" } }) expected = { "objects": [{ "url": "http://localhost/api/objects/uid00112233" }] } response = TestSuite.client.get(INDEX_ROUTE) self.assertEquals(json.loads(response.data), expected)
def testPutIdempotent(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) putObject = {"FieldThree" : "Three", "Field4" : 4} firstResponse = TestSuite.client.put(INDEX_ROUTE + uid, data = json.dumps(putObject), content_type = 'application/json') secondResponse = TestSuite.client.put(INDEX_ROUTE + uid, data = json.dumps(putObject), content_type = 'application/json') self.assertEquals(json.loads(firstResponse.data), json.loads(secondResponse.data)) self.assertEquals(len(TestSuite.getServerObjects()), 1)
def testPutBrokenJSON(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) expected = { "message": "400: Bad Request", "url": "http://localhost/api/objects/uid00112233", "verb": "PUT" } response = TestSuite.client.put(INDEX_ROUTE + uid, data = '{ "field1" : "brokendata }', content_type = 'application/json') self.assertEquals(json.loads(response.data), expected) self.assertEquals(len(TestSuite.getServerObjects()), 1) self.assertEquals(TestSuite.getServerObjects()[uid], initial)
def testPost(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) postObject = {"FieldThree" : "Three", "Field4" : 4} expected = { "message": "405: Method Not Allowed", "url": "http://localhost/api/objects/uid00112233", "verb": "POST" } response = TestSuite.client.post(INDEX_ROUTE + uid, data=json.dumps(postObject), content_type = 'application/json') self.assertEquals(json.loads(response.data), expected)
def testPutWrongUid(self): uid = "uid00112233" initial = {"FieldOne" : "One", "Field2" : 2, "uid" : uid} TestSuite.setServerObjects({uid : initial}) expected = { "message": "404: Not Found", "url": "http://localhost/api/objects/uid9999", "verb": "PUT" } putObject = {"FieldThree" : "Three", "Field4" : 4} response = TestSuite.client.put(INDEX_ROUTE + "uid9999", data = json.dumps(initial), content_type = 'application/json') self.assertEquals(json.loads(response.data), expected) self.assertEquals(len(TestSuite.getServerObjects()), 1) self.assertEquals(TestSuite.getServerObjects()[uid], initial)
def testPostRepeat(self): TestSuite.setServerObjects({}) postObject = { "field1" : "data1", "field two" : 2 } firstResponse = TestSuite.client.post(INDEX_ROUTE, data = json.dumps(postObject), content_type = 'application/json') secondResponse = TestSuite.client.post(INDEX_ROUTE, data = json.dumps(postObject), content_type = 'application/json') firstResponseObject = json.loads(firstResponse.data) secondResponseObject = json.loads(secondResponse.data) # Check that the only differentiating factor between the two objects is the uid self.assertNotEqual(firstResponseObject, secondResponseObject) del firstResponseObject["uid"] del secondResponseObject["uid"] self.assertEquals(firstResponseObject, secondResponseObject)
def testPostRepeat(self): TestSuite.setServerObjects({}) postObject = {"field1": "data1", "field two": 2} firstResponse = TestSuite.client.post(INDEX_ROUTE, data=json.dumps(postObject), content_type='application/json') secondResponse = TestSuite.client.post(INDEX_ROUTE, data=json.dumps(postObject), content_type='application/json') firstResponseObject = json.loads(firstResponse.data) secondResponseObject = json.loads(secondResponse.data) # Check that the only differentiating factor between the two objects is the uid self.assertNotEqual(firstResponseObject, secondResponseObject) del firstResponseObject["uid"] del secondResponseObject["uid"] self.assertEquals(firstResponseObject, secondResponseObject)
def run(): if "--test" in sys.argv: testUnit = TestSuite.TestUnit("convert") for directory in testUnit.directoriesToTest: try: print "Testing Directory " + directory convert(directory) except: testUnit.testFailure(directory) testUnit.checkOutcomes() else: convert()
def testPostMultipleObjects(self): TestSuite.setServerObjects({}) postObject = [ { "field1" : "data1", "field two" : 2 }, { "field3" : "data3", "field four" : 4 } ] response = TestSuite.client.post(INDEX_ROUTE, data = json.dumps(postObject), content_type = 'application/json') responseObject = json.loads(response.data) # Check that a list of objects is returned with the correct number of entries self.assertTrue(isinstance(responseObject["objects"], list)) self.assertEquals(len(responseObject["objects"]), len(postObject)) # Check that each has a uid and that the uid is present in the server's stored objects for item in responseObject["objects"]: self.assertTrue("uid" in item) self.assertTrue(item["uid"] in TestSuite.getServerObjects())
def testPostSingleObject(self): TestSuite.setServerObjects({}) postObject = { "field1" : "data1", "field two" : 2 } response = TestSuite.client.post(INDEX_ROUTE, data = json.dumps(postObject), content_type = 'application/json') responseObject = json.loads(response.data) # Check that response contains a UID self.assertTrue("uid" in responseObject) self.assertTrue(responseObject["uid"]) # Check that response contains the same keys and values as request for key in postObject: self.assertTrue(key in responseObject) self.assertEquals(postObject[key], responseObject[key]) # Check that response is present in the server's stored objects self.assertEquals(TestSuite.getServerObjects()[responseObject["uid"]], responseObject)
def testPostSingleObject(self): TestSuite.setServerObjects({}) postObject = {"field1": "data1", "field two": 2} response = TestSuite.client.post(INDEX_ROUTE, data=json.dumps(postObject), content_type='application/json') responseObject = json.loads(response.data) # Check that response contains a UID self.assertTrue("uid" in responseObject) self.assertTrue(responseObject["uid"]) # Check that response contains the same keys and values as request for key in postObject: self.assertTrue(key in responseObject) self.assertEquals(postObject[key], responseObject[key]) # Check that response is present in the server's stored objects self.assertEquals(TestSuite.getServerObjects()[responseObject["uid"]], responseObject)
def main(): if "--convert" in sys.argv: convert.run() if "--test" in sys.argv: testUnit = TestSuite.TestUnit("main") for directory in testUnit.directoriesToTest: try: print "Testing Directory " + directory processLogs(directory, TESTING_UNZIPPED_SIZE_LIMIT, TESTING_ZIPPED_SIZE_LIMIT) except: testUnit.testFailure(directory) testUnit.checkOutcomes() else: while True: processLogs() time.sleep(INTERVAL)
def realm_test(): """ Testing apparatus for realm of reckoning """ suite = TestSuite.TestSuite() print "\n-----Testing Character-----" test_char = Character('male', 'Rick', 10, 5, 5, 0, [], [0, 0]) print "character:", test_char print "\nTesting set_coords get_coords and get_coord..." suite.run_test(test_char.get_coords(), [0, 0], "Test 1:") test_char.set_coords([1, 1]) suite.run_test(test_char.get_coords(), [1, 1], "Test 2:") test_char.set_coords([5, 3]) suite.run_test(test_char.get_coord(0), 5, "Test 3:") test_char.set_coords([1, 2]) suite.run_test(test_char.get_coord(1), 2, "Test 4:") print "\nTesting attrib_list (check visually)..." suite.run_test(test_char.attrib_list(), None, "Test 5:") print "\nTesting add_to_inventory and get_inventory (check visually)..." print "Adding 'flint' and 'eggs' to inventory ..." suite.run_test(test_char.add_to_inventory('flint'), True, "Test 6:") suite.run_test(test_char.add_to_inventory('eggs'), True, "Test 7:") suite.run_test(test_char.get_inventory(), ['flint', 'eggs'], "Test 8:") print "\n" suite.report_results()
#coding=utf-8 import sys import os curPath = os.path.abspath(os.path.dirname(__file__)) rootPath = os.path.split(curPath)[0] sys.path.append(rootPath) import TestSuite sys.path.append("..") from public import BaseFunction, SendEmail '''测试入口''' if __name__ == "__main__": # 运行所有case BaseFunction.Report().run(TestSuite.createsuite()) SendEmail.SendReport_Email() #发送邮件
node = doc.createElementNS('www.fourthought.com', 'ft:Node4') if nm.setNamedItemNS(node) != None: tester.error('setNamedItemNS returns a value; should be (null)') tester.testDone() tester.startTest("Testing getNamedItemNS()") if nm.getNamedItemNS('www.fourthought.com', 'Node4').nodeName != node.nodeName: tester.error("getNamedItemNS failed") tester.testDone() tester.startTest("Testing removeNamedItemNS()") if nm.removeNamedItemNS('www.fourthought.com', 'Node4').nodeName != node.nodeName: tester.error("removeNamedItemNS failed") if nm.length != 1: tester.error("removeNamedItemNS failed") tester.testDone() return tester.groupDone() if __name__ == '__main__': import sys import TestSuite testSuite = TestSuite.TestSuite() retVal = test(testSuite) sys.exit(retVal)
import TestSuite def stopwatch(ticks): minutes = ticks/600 seconds = (ticks%600)/10 tenths = (ticks%600)%10 tenSeconds = seconds/10 seconds = seconds%10 msg = str(minutes) + ':' + str(tenSeconds) + str(seconds) + '.' + str(tenths) return msg TestSuite.runSuite(stopwatch, [100,200,6000], ['0:10.0', '200','10:00.0'])
"""Invokes CMake and make to create the test binaries. Calls a debug build as I don't want optimizations to get in the way.""" subprocess.call( ["cmake", "-DCMAKE_BUILD_TYPE=Debug", ts.TEST_PROGRAMS_FOLDER], cwd=ts.TEST_PROGRAMS_FOLDER) subprocess.call(["make"], cwd=ts.TEST_PROGRAMS_FOLDER) print "All test programs compiled." def run_and_core(executable): """Start the test program, then takes a core dump and kills it.""" test_program = subprocess.Popen( [os.path.join(ts.TEST_PROGRAMS_FOLDER, executable)]) pid = str(test_program.pid) time.sleep(1) # Theoretically incorrect, but sufficient for our purposes. subprocess.call([ "sudo", "gcore", "-o", os.path.join(ts.CORES_FOLDER, executable), pid ]) subprocess.call(["kill", pid]) print "Created core file for " + executable if __name__ == "__main__": clean_up_core_folder() compile_test_programs() executables = ts.find_test_cases() for program in executables: print "Working on " + program run_and_core(program)
suite = [] import test_AS, test_PLC, test_BS, test_BT, test_MCMC, test_HN, test_FC, test_htt suite += test_AS.suite # asymptotic CLs suite += test_PLC.suite # profile likelihood suite += test_BS.suite # bayes simple suite += test_BT.suite # bayes toymc suite += test_MCMC.suite # bayes mcmc suite += test_HN.suite # hybrid new suite += test_FC.suite # feldman cousins suite += test_htt.suite # all htt tests from TestSuite import * dir = options.name if options.name else options.suite thisSuite = TestSuite(dir, options, suite) for cmd in args: if cmd == "list": thisSuite.listJobs() elif cmd == "create": print "Creating test suite in directory",dir thisSuite.createJobs() print "Done." elif cmd == "run": if options.threads: thisSuite.runLocallyASync(threads=options.threads) else: thisSuite.runLocallySync() elif cmd == "submit": thisSuite.runBatch(options.queue) elif cmd == "report":
def main(): # default directory for the tests: the current working directory # @todo: test these cwd = os.path.abspath(os.getcwd()) # default script file path: in the parent directory a zip file # whose basename is identical to the basename of the current working # directory script_source = cwd + "../" + os.path.basename(cwd) + ".zip" # for testing: cwd = '/Users/csaba/Dropbox/Public/CMPUT-174-2012-Fall/assignments/as-174-2-marking-basic' script_source = '/Users/csaba/Dropbox/Public/CMPUT-174-2012-Fall/assignments/as-174-2' parser = argparse.ArgumentParser( description='Run tests against a submission file.' # , epilog='''aaa''' ) parser.add_argument('--submission', '-s', default=script_source, help='Scripts to be tested again (zip or dir)') parser.add_argument( '--test_directory', '-t', default=cwd, help='Directory containing the tests (defaults to current)') parser.add_argument('--verbose', '-v', action='store_true', help='show the detailed outcome of the tests') parser.add_argument('--visible_space_diff', '-p', action='store_true', help='show the results of the diff') parser.add_argument('--timeout', type=int,default=200 , help='Terminate the script with an error after the '\ 'timeout has passed') parser.add_argument('--generate', '-g', action='store_true', help='generates expected outputs') # parser.add_argument('--pep8', action='store_true' # , help='Run pep8 on the source files') parser.add_argument('--wait_on_exit', '-w', action='store_true' , help='Exit on finish instead of pausing and waiting '\ 'for the user') parser.add_argument( '--verify_script_dir', action='store_true', help='Verify whether the script directory is correctly formatted') parser.add_argument('--python_only', action='store_true', help='Allow python only') args = parser.parse_args() testcase_source = os.path.abspath(os.getcwd()) if args.test_directory: testcase_source = args.test_directory try: any_language = not args.python_only print("Creating test suite") test_suite = TestSuite.TestSuite(testcase_source, any_language) print("Collecting script-tests") test_suite.collect_tests(create_missing_dirs=False) print("Collected %s script-tests" % len(test_suite.test_cases)) print("Verifying submission files") script_source = args.submission script_dir = TestSuite.prep_submission(script_source, test_suite.assignment_name, args.verify_script_dir) print("Running tests") test_suite.run_tests(script_dir, timeout=args.timeout, gen_res=args.generate, visible_space_diff=args.visible_space_diff, verbose=args.verbose, stop_early=False) summary = test_suite.get_summary() print( "Number of tests: %s Errors: %s Serious failures: %s All failures: %s" % summary) # report the results if args.wait_on_exit: input("Press <Enter> to exit") except RuntimeError as err: print("Error:\n" + str(err))
test.run(self.result) assert ("1 run, 0 failed" == self.result.summary()) def testFailedResult(self): test = WasRun("testBrokenMethod") test.run(self.result) assert ("1 run, 1 failed" == self.result.summary()) def testFailedResultFormatting(self): self.result.testStarted() self.result.testFailed() assert ("1 run, 1 failed" == self.result.summary()) def testSuite(self): suite = TestSuite() suite.add(WasRun("testMethod")) suite.add(WasRun("testBrokenMethod")) suite.run(self.result) assert ("2 run, 1 failed" == self.result.summary()) suite = TestSuite() suite.add(TestCaseTest("testTemplateMethod")) suite.add(TestCaseTest("testResult")) suite.add(TestCaseTest("testFailedResult")) suite.add(TestCaseTest("testFailedResultFormatting")) suite.add(TestCaseTest("testSuite")) result = TestResult() suite.run(result) print(result.summary())
from TestSuite import * from Trial import * from itertools import combinations radius = 1 suite_id = 1 flag_num = 5 distance = 7.46 ts1 = TestSuite(suite_id, flag_num, distance) ts1.generate() file_name = './test_' + str(flag_num) + '_' + str(distance) + '.json' ts1.save(file_name)
def main(): # default directory for the tests: the current working directory #@todo: test these cwd = os.path.abspath(os.getcwd()) # default script file path: in the parent directory a zip file # whose basename is identical to the basename of the current working directory script_source = cwd+"../"+os.path.basename(cwd)+".zip" # for testing: cwd = '/Users/csaba/Dropbox/Public/CMPUT-174-2012-Fall/assignments/as-174-2-marking-basic' script_source = '/Users/csaba/Dropbox/Public/CMPUT-174-2012-Fall/assignments/as-174-2' parser = argparse.ArgumentParser( description='Run tests against a submission file.' # , epilog='''aaa''' ) parser.add_argument('--submission', '-s', default=script_source , help='Scripts to be tested again (zip or dir)') parser.add_argument('--test_directory', '-t', default = cwd , help='Directory containing the tests (defaults to current)' ) parser.add_argument('--verbose', '-v', action='store_true' , help='show the detailed outcome of the tests') parser.add_argument('--visible_space_diff', '-p', action='store_true' , help='show the results of the diff') parser.add_argument('--timeout', type=int,default=200 , help='Terminate the script with an error after the '\ 'timeout has passed') parser.add_argument('--generate', '-g', action='store_true' , help='generates expected outputs') # parser.add_argument('--pep8', action='store_true' # , help='Run pep8 on the source files') parser.add_argument('--wait_on_exit', '-w', action='store_true' , help='Exit on finish instead of pausing and waiting '\ 'for the user') parser.add_argument('--verify_script_dir', action='store_true' , help='Verify whether the script directory is correctly formatted') args = parser.parse_args() testcase_source = os.path.abspath(os.getcwd()) if args.test_directory: testcase_source = args.test_directory try: print("Creating test suite") test_suite = TestSuite.TestSuite(testcase_source) print("Collecting script-tests") test_suite.collect_tests(create_missing_dirs=False) print("Collected %s script-tests" % len(test_suite.test_cases)) print("Verifying submission files") script_source = args.submission script_dir = TestSuite.prep_submission(script_source,test_suite.assignment_name,args.verify_script_dir) print("Running tests") test_suite.run_tests(script_dir,timeout=args.timeout,gen_res=args.generate ,visible_space_diff=args.visible_space_diff ,verbose=args.verbose ) summary = test_suite.get_summary() print("Number of tests: %s\tErrors: %s\tSoft-test failures: %s\tHard-test failures: %s" % summary ) # report the results if args.wait_on_exit: input("Press <Enter> to exit") except RuntimeError as err: print("Error:\n"+str(err))
<td style="color:green; font-weight:bold">""" + str( countpass) + """</td> </tr> <tr> <td>Fail</td> <td style="color:red; font-weight:bold">""" + str(countfail) + """</td> </tr> <tr> <td>Total</td> <td style="color:orange; font-weight:bold">""" + str( countfail + countpass) + """</td> </tr> </table> </body> </html>""" # message = message.format(countpass=str(self.countpass),countfail=str(self.countfail),counttotal=str(self.total)) # return message f.write(message) f.close() f = open(resultsHtml, 'w') f.close() with open(testSuiteFile) as data_file: data = json.load(data_file) for testName in data["testCases"]: testSuite = TestSuite(testName) countpass, countfail = testSuite.begin() testName = testName.split("/")[-1] writeResults(testName, countpass, countfail)
import sys if not ("src") in sys.path: sys.path.append("src") import TestSuite reload(TestSuite) TestSuite.run()
ArgumentsList = list(map(str, ArgumentString.split(','))) path = os.getcwd() new_path = os.path.join(path, 'TestSuites') TestCases = [] for filename in os.listdir(new_path): for foldername in ArgumentsList: if foldername == filename: for jsonfilename in os.listdir(os.path.join(new_path, foldername)): if (jsonfilename[-5:] == '.json'): TestCases.append(foldername + "/" + jsonfilename[:-5]) data = {} data['testCases'] = TestCases ActualResult = TestCases os.chdir(path) for testName in data["testCases"]: TotalTestCases += 1 testSuite = TestSuite(testName, TestCases) countpass, countfail, passed_list, failed_list, utterancesList = testSuite.begin( ) passed_data = passed_list failed_data.append(failed_list) writeResults(testName, countpass, countfail, utterancesList) path = os.getcwd() new_path = os.path.join(path, 'TestSuites') os.chdir(new_path) filenames = [] for filename in TestCases: filenames.append(filename + '.xlsx') os.chdir(path) writeSummary(filenames)
tester.error('splitText did not properly split first half') if t2.data != 'TWO': tester.error('splitText did not properly split second half') try: t.splitText(100) except DOMException, x: if x.code != INDEX_SIZE_ERR: name = get_exception_name(x.code) tester.error("Wrong exception '%s', expected INDEX_SIZE_ERR" % name) else: tester.error('splitText doesn\'t catch an invalid index') tester.testDone() tester.startTest('Testing cloneNode()') t3 = t.cloneNode(0) if t3.data != t.data: error("cloneNode does not copy data") tester.testDone() return tester.groupDone() if __name__ == '__main__': import sys import TestSuite tester = TestSuite.TestSuite() retVal = test(tester) sys.exit(retVal)
def testFailedResult(self): test= WasRun("testBrokenMethod") test.run(self.result) assert("1 run, 1 failed", result.summary()) def testFailedResultFormatting(self): self.result.testStarted() self.result.testFailed() assert("1 run, 1 failed" == self.result.summary()) def testSuite(self): suite= TestSuite() suite.add(WasRun("testMethod")) suite.add(WasRun("testBrokenMethod")) suite.run(self.result) assert("2 run, 1 failed" == self.result.summary()) suite= TestSuite() suite.add(TestCaseTest("testTemplateMethod")) suite.add(TestCaseTest("testResult")) suite.add(TestCaseTest("testFailedResultFormatting")) suite.add(TestCaseTest("testFailedResult")) suite.add(TestCaseTest("testSuite")) result= TestResult() suite.run(result) print (result.summary())
def testSuite(self): suite = TestSuite() suite.add(WasRun("testMethod")) suite.add(WasRun("testBrokenMethod")) suite.run(self.result) assert ("2 run, 1 failed" == self.result.summary())
def testSuite(self): suite= TestSuite() suite.add(WasRun("testMethod")) suite.add(WasRun("testBrokenMethod")) suite.run(self.result) assert("2 run, 1 failed" == self.result.summary())
suite = [] import test_AS, test_PLC, test_BS, test_BT, test_MCMC, test_HN, test_FC, test_htt suite += test_AS.suite # asymptotic CLs suite += test_PLC.suite # profile likelihood suite += test_BS.suite # bayes simple suite += test_BT.suite # bayes toymc suite += test_MCMC.suite # bayes mcmc suite += test_HN.suite # hybrid new suite += test_FC.suite # feldman cousins suite += test_htt.suite # all htt tests from TestSuite import * dir = options.name if options.name else options.suite thisSuite = TestSuite(dir, options, suite) for cmd in args: if cmd == "list": thisSuite.listJobs() elif cmd == "create": print "Creating test suite in directory", dir thisSuite.createJobs() print "Done." elif cmd == "run": if options.threads: thisSuite.runLocallyASync(threads=options.threads) else: thisSuite.runLocallySync() elif cmd == "submit": thisSuite.runBatch(options.queue) elif cmd == "report":
from homework import * from TestSuite import * # ------------------------------------ # Insert your merge function here # ------------------------------------ # ------------------------------------ # testing # ------------------------------------ # create a TestSuite object suite = TestSuite() game= TwentyFortyEight(3, 3) game.new_tile() game.new_tile() game.new_tile() game.new_tile() game.new_tile() game.new_tile() game.new_tile() game.new_tile() # test format_function on various inputs #suite.run_test(game., "Test #1:")