def run_subsuite(args): # type: (SubsuiteArgs) -> Tuple[int, Any] # Reset the accumulated INSTRUMENTED_CALLS before running this subsuite. test_helpers.INSTRUMENTED_CALLS = [] if len(args) == 4: # This condition runs for Django 1.11. The first argument is the # test runner class but we don't need it because we run our own # version of the runner class. args = cast(Tuple[Type[RemoteTestRunner], int, SerializedSubsuite, bool], args) _, subsuite_index, subsuite, failfast = args else: # We are making mypy to ignore the following line because # it is only valid in Django 1.10. In Django 1.11, this # tuple is made up of 4 elements. args = cast(Tuple[int, SerializedSubsuite, bool], args) subsuite_index, subsuite, failfast = args runner = RemoteTestRunner(failfast=failfast) result = runner.run(deserialize_suite(subsuite)) # Now we send instrumentation related events. This data will be # appended to the data structure in the main thread. For Mypy, # type of Partial is different from Callable. All the methods of # TestResult are passed TestCase as the first argument but # addInstrumentation does not need it. process_instrumented_calls(partial(result.addInstrumentation, None)) # type: ignore return subsuite_index, result.events
def run_subsuite(args): # type: (SubsuiteArgs) -> Tuple[int, Any] # Reset the accumulated INSTRUMENTED_CALLS before running this subsuite. test_helpers.INSTRUMENTED_CALLS = [] if len(args) == 4: # This condition runs for Django 1.11. The first argument is the # test runner class but we don't need it because we run our own # version of the runner class. args = cast( Tuple[Type[RemoteTestRunner], int, SerializedSubsuite, bool], args) _, subsuite_index, subsuite, failfast = args else: # We are making mypy to ignore the following line because # it is only valid in Django 1.10. In Django 1.11, this # tuple is made up of 4 elements. args = cast(Tuple[int, SerializedSubsuite, bool], args) subsuite_index, subsuite, failfast = args runner = RemoteTestRunner(failfast=failfast) result = runner.run(deserialize_suite(subsuite)) # Now we send instrumentation related events. This data will be # appended to the data structure in the main thread. For Mypy, # type of Partial is different from Callable. All the methods of # TestResult are passed TestCase as the first argument but # addInstrumentation does not need it. process_instrumented_calls(partial(result.addInstrumentation, None)) # type: ignore return subsuite_index, result.events
def run_subsuite(args): # type: (Tuple[int, Tuple[Type[Iterable[TestCase]], List[str]], bool]) -> Tuple[int, Any] subsuite_index, subsuite, failfast = args runner = RemoteTestRunner(failfast=failfast) result = runner.run(deserialize_suite(subsuite)) # Now we send instrumentation related events. This data will be # appended to the data structure in the main thread. For Mypy, # type of Partial is different from Callable. All the methods of # TestResult are passed TestCase as the first argument but # addInstrumentation does not need it. process_instrumented_calls(partial(result.addInstrumentation, None)) # type: ignore return subsuite_index, result.events
def run_subsuite(args: SubsuiteArgs) -> Tuple[int, Any]: # Reset the accumulated INSTRUMENTED_CALLS before running this subsuite. test_helpers.INSTRUMENTED_CALLS = [] # The first argument is the test runner class but we don't need it # because we run our own version of the runner class. _, subsuite_index, subsuite, failfast = args runner = RemoteTestRunner(failfast=failfast) result = runner.run(deserialize_suite(subsuite)) # Now we send instrumentation related events. This data will be # appended to the data structure in the main thread. For Mypy, # type of Partial is different from Callable. All the methods of # TestResult are passed TestCase as the first argument but # addInstrumentation does not need it. process_instrumented_calls(partial(result.addInstrumentation, None)) return subsuite_index, result.events
def run_subsuite(collect_coverage, args): # type: (bool, Tuple[int, Tuple[Type[Iterable[TestCase]], List[str]], bool]) -> Tuple[int, Any] if collect_coverage: cov = coverage.Coverage(config_file="tools/coveragerc", data_suffix=True) cov.start() # Reset the accumulated INSTRUMENTED_CALLS before running this subsuite. test_helpers.INSTRUMENTED_CALLS = [] subsuite_index, subsuite, failfast = args runner = RemoteTestRunner(failfast=failfast) result = runner.run(deserialize_suite(subsuite)) # Now we send instrumentation related events. This data will be # appended to the data structure in the main thread. For Mypy, # type of Partial is different from Callable. All the methods of # TestResult are passed TestCase as the first argument but # addInstrumentation does not need it. process_instrumented_calls(partial(result.addInstrumentation, None)) # type: ignore if collect_coverage: cov.stop() cov.save() return subsuite_index, result.events
# -*- coding: utf-8 -*- import os import sys import unittest.runner _dir = os.path.dirname(__file__) def suite(): test_loader = unittest.TestLoader() test_suite = test_loader.discover(_dir, 'test_*.py') return test_suite if __name__ == '__main__': runner = unittest.TextTestRunner() result = runner.run(suite()) sys.exit(not result.wasSuccessful())
# #调整第一第二排名 # num_2 = element("/html/body/div[1]/div/div[2]/div[2]/div/div/div[3]/div/div/div[2]/div[1]/div/label[2]/span[1]/span") # num_2.click() # #点击上移按钮 # up_button = element("/html/body/div[1]/div/div[2]/div[2]/div/div/div[3]/div/div/div[2]/div[2]/div[1]") # up_button.click() # #点击保存按钮 # save_button2 = element("/html/body/div[1]/div/div[2]/div[2]/div/div/div[3]/div/div/div[3]/button") # save_button2.click() # # Alert弹框对象 # a3 = Alert(self.driver) # time.sleep(1) # #接受弹框信息并关闭 # a3.accept() # time.sleep(3) def test_tearDown(self): #关闭浏览器 self.driver.quit() if __name__ == "__main__": test_suite = unittest.TestSuite() #将测试用例加入到测试容器中 test_suite.addTest(test_APP_Manage("test_app_manage")) #当做报告文件的名称 filename = 'C:\\result' #打开一个文件,将result写入此file中 fp = open(filename+'.html','wb') runner = HTMLTestRunner(stream = fp, title = u"Web UI自动化测试报告", description = u"result:") runner.run(test_suite) fp.close()
print('/admin/login接口没问题') file = open('admintoken', "w+") file.write(request['data']['token']) file.close() else: print('/admin/login接口有问题') print('返回状态码:' + str(request['result'])) def test_categorygameslist(self): url = self.host + '/games/categorygameslist' token = open('admintoken', 'r') gettoken = token.read() token.close() self.headers['Access-Token'] = gettoken request = requests.get(url, headers=self.headers).json() print(request) if request['result'] == 200000: print('/games/categorygameslist接口没问题') else: print('/games/categorygameslist接口有问题') print('返回状态码:' + str(request['result'])) print('msg' + request['msg']) print(request) def tearDown(self) -> None: print('运行完毕') if __name__ == '__main__': runner.run()
import os.path import sys import unittest import unittest.runner def suite(): test_loader = unittest.TestLoader() test_suite = test_loader.discover( os.path.dirname(__file__), pattern='test_*.py') return test_suite if __name__ == '__main__': runner = unittest.runner.TextTestRunner() result = runner.run(suite()) sys.exit(not result.wasSuccessful())
else: args.loglevel='WARNING' util.log.setLogLevel(args.loglevel) if args.loglevel == 'DEBUG': opt('debug', True) options.override(vars(args)) if opt('tests'): import unittest import unittest.runner tests = unittest.defaultTestLoader.discover('braille.tests', pattern='test*.py') runner = unittest.runner.TextTestRunner() runner.run(tests) elif opt('gui'): from . import gui gui.__main__() else: oline = "" while (True): line = sys.stdin.readline() oline = convert(line) #Helps readability on monospace outputs--like a terminal oline = oline.replace('', ' ') print oline.strip()
import os from unittest import TestLoader, TextTestRunner from unittest import runner """ blender -b -P discover_tests.py """ print(f'{__file__} __package__:' + str(__package__)) if __name__ == "__main__": loader = TestLoader() test = loader.discover(os.getcwd(), top_level_dir=os.path.dirname(os.getcwd())) runner = TextTestRunner() runner.run(test)
''' Created on Feb 4, 2019 @author: siddardha.teegela ''' import unittest from unittest import runner from unittest_demo.TestStringMethods import TestStringMethods def suite(): suite = unittest.TestSuite() suite.addTest(TestStringMethods('test_upper')) suite.addTest(TestStringMethods('test_isUpper')) suite.addTest(TestStringMethods('test_split')) return suite if __name__ == '__main__': runner = unittest.TextTestRunner() runner.run(suite())
# coding=utf-8 import unittest.case import unittest.runner import unittest.result import unittest.suite import HTMLTestRunner import time import sys import os reload(sys) sys.setdefaultencoding("utf-8") suit = unittest.TestSuite() os.chdir("D:\Users\zhyimei\PycharmProjects\echo\case") os.system("python excute.py") print "测试结束" now = time.strftime("%y-%m-%d-%H-%M-%S", time.localtime(time.time())) report = "D:\\测试报告\\" + now + ".html" fp = open(report, "wb") runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title="测试报告", description="echo_1.3.7") runner.run(suit)