sách gpt4 ai đã đi

python - 使用 nose.run() 或 nose.main() 在特定模块中运行测试

In lại Tác giả: Space Dog 更新时间:2023-10-29 20:42:17 27 4
mua khóa gpt4 Nike

它在文档中提到 ( http://nose.readthedocs.org/en/latest/api/core.html ) 但似乎没有任何示例,并且尝试它似乎在 cwd 中运行所有测试。

1 Câu trả lời

Hãy thử cách này:

测试模块.py:

nhập khẩu ghi nhật ký
nhập khẩu hệ thống

import nose

logging.basicConfig(level=logging.INFO)

#here are some tests in this module
def test_me():
vượt qua

nếu __name__ == '__main__':
#This code will run the test in this file.'

module_name = sys.modules[__name__].__file__
logging.debug("running nose for package: %s", module_name)

result = nose.run(argv=[sys.argv[0],
module_name,
'-v'])
logging.info("all tests ok: %s", result)

python test_module.py 会让你:

test_module.test_me ... ok

-----------------------------------------------------------------------------------
Ran 1 test in 0.001s

ĐƯỢC RỒI
INFO:root:all tests ok: True

关于python - 使用 nose.run() 或 nose.main() 在特定模块中运行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23001642/

27 4 0
Bài viết được đề xuất: python - 在单个 HTML 页面上显示多个 mpld3 导出
Bài viết được đề xuất: c++ - 错误的十六进制代码
Bài viết được đề xuất: c# - 使用 C# 向 Paradox 表插入查询的问题
Bài viết được đề xuất: c++ - void_ptr++ 不起作用,但 void_ptr+= 起作用
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com