我的nox函数看起来像这样
@nox.session(python=["3.7", "3.8", "3.9"])
def test(session: nox.Session) -> None:
"""Run unit tests."""
session.install("-e", ".[all]")
session.install("-e", ".[tests]")
print (session.posargs)
session.run("pytest", *session.posargs)如何更新上述函数以运行特定文件或文件模式(如tests/*/test_postgres_*.py )的测试
发布于 2022-04-06 03:29:04
下面是一个演示如何使用参数对特定文件运行测试的快速示例:
@nox.session
def test(session):
session.install('pytest')
if session.posargs:
test_files = session.posargs
else:
test_files = ['test_a.py', 'test_b.py']
session.run('pytest', *test_files)你跑:
nox -- test_c.py然后nox将运行:
pytest test_c.pyhttps://stackoverflow.com/questions/71493859
复制相似问题