HttpRunner3的变量是如何传递的

HttpRunner3的变量可以在测试类的用例配置中通过variables添加,也可以在测试步骤中使用extract()、with_jmespath()提取出来放到变量x,再用$x传递给下一个接口使用,比如登录到下单流程的部分测试脚本如下:

pytest内置和自定义marker

可以通过命令行查看所有marker,包括内置和自定义的

Python运算符可不只有加减乘除

数学里面的加减乘除,就是运算符,但是 Python 的运算符更多样,更复杂,分为算术运算符、比较运算符、赋值运算符、位运算符、逻辑运算符、成员运算符、身份运算符。为了更直观的看到运算符的使用,本文采用代码和注释结合的方式进行讲解。

Django官方为什么没有标准项目结构

Django官方并没有提供标准的项目结构,于是网上众说纷纭,百花齐放,一千个读者有一千个哈姆雷特。那我们该怎么设计项目结构呢?在回答这个问题之前,先了解一下Django原生的目录和文件都是干嘛的。

Flask官方推荐项目结构竟然是这样

Flask有个特点:千人千面。它没有硬性规定,你必须采用哪种项目结构来组织代码,这就导致每个人都按照自己的习惯和喜好来写,写出来的项目结构往往是千差万别。在Flask2.0的官方文档中,有一节内容介绍了Flask的项目结构,我们可以窥探一番。

2026-01-03 · 1 分钟 · 119 字 · 测试开发刚哥 · Python生态 · #Flask

HttpRunner3的用例是怎么运行起来的

在PyCharm中打开examples/httpbin/basic_test.py:

pytest精通fixture

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 fixture是什么 看看源码 def fixture( callable_or_scope=None, *args, scope="function", params=None, autouse=False, ids=None, name=None ): """Decorator to mark a fixture factory function. This decorator can be used, with or without parameters, to define a fixture function. The name of the fixture function can later be referenced to cause its invocation ahead of running tests: test modules or classes can use the ``pytest.mark.usefixtures(fixturename)`` marker. Test functions can directly use fixture names as input arguments in which case the fixture instance returned from the fixture function will be injected. Fixtures can provide their values to test functions using ``return`` or ``yield`` statements. When using ``yield`` the code block after the ``yield`` statement is executed as teardown code regardless of the test outcome, and must yield exactly once. :arg scope: the scope for which this fixture is shared, one of ``"function"`` (default), ``"class"``, ``"module"``, ``"package"`` or ``"session"`` (``"package"`` is considered **experimental** at this time). This parameter may also be a callable which receives ``(fixture_name, config)`` as parameters, and must return a ``str`` with one of the values mentioned above. See :ref:`dynamic scope` in the docs for more information. :arg params: an optional list of parameters which will cause multiple invocations of the fixture function and all of the tests using it. The current parameter is available in ``request.param``. :arg autouse: if True, the fixture func is activated for all tests that can see it. If False (the default) then an explicit reference is needed to activate the fixture. :arg ids: list of string ids each corresponding to the params so that they are part of the test id. If no ids are provided they will be generated automatically from the params. :arg name: the name of the fixture. This defaults to the name of the decorated function. If a fixture is used in the same module in which it is defined, the function name of the fixture will be shadowed by the function arg that requests the fixture; one way to resolve this is to name the decorated function ``fixture_<fixturename>`` and then use ``@pytest.fixture(name='<fixturename>')``. """ if params is not None: params = list(params) fixture_function, arguments = _parse_fixture_args( callable_or_scope, *args, scope=scope, params=params, autouse=autouse, ids=ids, name=name, ) scope = arguments.get("scope") params = arguments.get("params") autouse = arguments.get("autouse") ids = arguments.get("ids") name = arguments.get("name") if fixture_function and params is None and autouse is False: # direct decoration return FixtureFunctionMarker(scope, params, autouse, name=name)( fixture_function ) return FixtureFunctionMarker(scope, params, autouse, ids=ids, name=name) 总结一下 ...

关于FastAPI异步并发的技术背景和细节

FastAPI的路径操作函数,可以使用async def定义:

用PyCharm打个专业的招呼

本书作者:测试开发刚哥,文章版权归个人所有,未经授权请勿转载。 PyCharm 是什么 PyCharm(读作“拍恰姆”)是 JetBrains 全家桶中的一员,专门用来写 Python 的: 官方网址是: https://www.jetbrains.com/pycharm/ for Professional Developers,顾名思义,它是为专业开发者而生的。 版本选择 PyCharm 有 2 个版本: 左边的 Professional 是专业版,需要付( po )费( jie )。右边的 Community 是社区版,永久免费。一般社区版够用了。我用的是专业版,看着齐全。 打开 PyCharm 安装完成后,打开: 不需要导入配置,点击 OK 按钮: 有 2 个主题,个人偏好左边这种,酷酷的。点击左下角 Skip Remaining and Set Defaults 跳过插件安装,进入主界面(专业版破解后才能看到这个界面,具体破解方法网上贼多): 首次打开,还没有创建项目,会出现引导页。选择 New Project: 这是专业版的界面,社区版会简略一点。选择好存放目录后,还需要配置解释器。点击解释器右边的 ... ,切换到 System Interpreter,选择已经安装好的 Python: OK 后再点击 Create,来了: 老手可以勾选 Tip of the Day 左小角 Don't show tips。 ...

Django搭建示例项目实战与避坑细节

Django 开发项目是很快的,有多快?看完本篇文章,你就知道了。