python - pytest 应该运行在 test_module_A 的 test_func 中导入的 module_B
问题描述
这是我的代码
包:-一个
#test_module_A.py
def test_A1():
print('abc')
def test_A2():
import B.test_module_B
pkg:- B
#test_module_B.py
def test_B1():
print('def')
我正在使用 pytest 从 pycharm 运行 test_module_A
输出
美国广播公司
但是我希望输出是
abc
def
谁能帮我....
在实际场景中,test_module_B 在包内存在的 100 个模块中是动态的。
我希望 pytest 将其控制从 A2() 重定向到 module_B 然后完全执行它并再次返回到模块 A 并执行任何剩余的功能......
解决方案
您正在导入B.test_module_B
,但您并没有执行实际的测试。我想你想要以下内容:
def test_A2():
import B.test_module_B
B.test_module_B.test_B1()
推荐阅读
- asp.net-core - 从客户端清空多项选择
- sql - 关于 CockroachDB 上表创建错误的说明
- javascript - 当其 id 具有特殊字符时,jqGrid 寻呼机不显示
- ruby-on-rails - 局部形式的当地人-rails 5
- java - 如何将数据与文件一起发送?
- c# - 将文件从一个 API 端点流式传输到另一个 API 端点
- c# - 检查每个单选按钮组是否选择/选中了一个单选按钮
- python - 为 ruamel.yaml 中的所有字段添加一组新属性
- javascript - 无法从类名 js-menu 中读取值,它说无法读取属性类名
- android - 如何在使用 kotlin 关闭活动之前获取 textView 的信息?