How to use run_configure method in pyresttest

Best Python code snippet using pyresttest_python

main.py

Source:main.py Github

copy

Full Screen

1"""2@File : main.py3@Date : 2021/10/9 14:414@Author: 九层风(YePing Zhang)5@Contact : yeahcheung213@163.com6"""7from fastapi import FastAPI8from app.routers import (9 user_router, test_report_router,10 build_router, bug_router, dev_task_router,11 bug_related_evaluations_router,12 test_task_router,13 team_router,14 business_auto_deliver_test,15 business_auto_create_report,16 business_product_project,17 business_auto_distribute,18 tools_router,19 CD_server_router,20 CI_server_router)21from starlette.responses import RedirectResponse22from app.config import RUN_CONFIGURE23from app.utils.log_handle import *24from app.config import LOG_CONFIG25from pathlib import Path26import uvicorn27import sys28import os29# 引入日志模块30def init_app():31 application = FastAPI(title="eWordCIAPI 全网云CI系统", debug=LOG_CONFIG['IF_DEBUG'])32 logging.getLogger().handlers = [InterceptHandler()]33 logger.configure(34 handlers=[{"sink": sys.stdout, "level": logging.DEBUG, "format": format_record}])35 logger.add(LOG_CONFIG['LOG_PATH'], rotation=LOG_CONFIG['ROTATION'], encoding="utf-8", enqueue=True,36 retention=LOG_CONFIG['RETENTION'])37 logger.debug('日志系统已加载')38 logging.getLogger("uvicorn.access").handlers = [InterceptHandler()]39 return application40# 初始化app41app = init_app()42# app = FastAPI()43"""注册路由到app"""44# 基础数据45app.include_router(user_router.router)46app.include_router(build_router.router)47app.include_router(test_task_router.router)48app.include_router(test_report_router.router)49app.include_router(team_router.router)50app.include_router(bug_router.router)51app.include_router(dev_task_router.router)52# 业务53app.include_router(bug_related_evaluations_router.router)54app.include_router(business_auto_create_report.router)55app.include_router(business_product_project.router)56app.include_router(business_auto_deliver_test.router)57app.include_router(business_auto_distribute.router)58# 工具59app.include_router(tools_router.router)60# CD服务端61app.include_router(CD_server_router.router)62# CI63app.include_router(CI_server_router.router)64@app.get("/", name="WelCome to CIAPI!")65# 将根路径重定向到swagger文档66async def root():67 # return {"message": "Welcome to eWordCI"}68 return RedirectResponse(url="/docs")69if __name__ == "__main__":70 root_path = Path(__file__).parent # 获取当前文件的父路径71 os.chdir(root_path) # 切换程序运行目录72 # 脚本启动73 uvicorn.run(app='main:app', host="0.0.0.0", port=RUN_CONFIGURE['PORT'], reload=RUN_CONFIGURE['RELOAD'],74 debug=RUN_CONFIGURE['DEBUG'], workers=RUN_CONFIGURE['WORKERS'])75"""76命令行启动77部署到linux可以使用gunicorn框架做监控 https://www.jianshu.com/p/c292e2f79c2c78uvicorn main:app --host 0.0.0.0 --port 8889 --reload...

Full Screen

Full Screen

modules.py

Source:modules.py Github

copy

Full Screen

...5 module.set_injector(injector)6 self._module = module7 def configure(self, binder):8 if hasattr(self._module, 'run_configure'):9 self._module.run_configure(binder)10 else:11 self._module.configure(binder)12class Module(object):13 """Base class for all standard modules."""14 def __init__(self):15 self._injector = None16 def install(self, binder, module):17 """Add another module's bindings to a binder."""18 ModuleAdapter(module, self._injector).configure(binder)19 def run_configure(self, binder):20 """A hook for intercepting the configure method. Allows different21 module implementations to change the binder passed to configure.22 """23 self.configure(binder)24 def configure(self, binder):25 """A subclass should override this to configure a binder."""26 raise NotImplementedError27 def set_injector(self, injector):28 self._injector = injector29class _PrivateModuleWrapper(Module):30 """Exists solely to remove the infinite recursion in Private Modules31 caused by the child injector calling run_configure.32 """33 def __init__(self, module):34 self._module = module35 super(_PrivateModuleWrapper, self).__init__()36 def configure(self, binder):37 self._module.configure(binder)38class PrivateModule(Module):39 """Module that uses a child injector to isolate bindings."""40 def expose(self, binder, interface, annotation=None):41 """Expose the child injector to the parent inject for a binding."""42 private_module = self43 class Provider(object):44 def get(self):45 return private_module.private_injector.get_instance(46 interface, annotation)47 self.original_binder.bind(interface, annotated_with=annotation,48 to_provider=Provider)49 def run_configure(self, binder):50 self.original_binder = binder51 private_module = _PrivateModuleWrapper(self)...

Full Screen

Full Screen

modules_spec.py

Source:modules_spec.py Github

copy

Full Screen

...16 assert simple_module.configure.call_args == ((binder,), {})17 def when_installing_a_standard_module():18 class FakeModule(Module):19 calls = []20 def run_configure(self, binder):21 self.calls.append(('run_configure', binder))22 return super(FakeModule, self).run_configure(binder)23 def configure(self, binder):24 self.calls.append(('configure', binder))25 standard_module = FakeModule()26 mod.install(binder, standard_module)27 def then_the_run_configure_method_is_called_with_binder():28 assert ('run_configure', binder) in FakeModule.calls29 def then_the_configure_method_is_called_with_the_same_binder():30 assert ('configure', binder) in FakeModule.calls31 def when_not_overriding_configure():32 @raises(NotImplementedError)33 def then_an_NotImplementedError_should_be_raised():...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyresttest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful