如何获取当前运行的nox会话的名称?例如,要使用名称来自定义覆盖率文件:
import nox
@nox.session(python=['3.6', '3.7', '3.8', '3.9'])
def test(session):
session.install('.')
session.install('pytest', 'pytest-cov')
session.env['COVERAGE_FILE'] = f'.coverage.{session.name}' # <-- what do I put here?
session.run('python', '-m', 'pytest', '--cov', 'tests/')发布于 2021-02-14 09:33:28
有关此信息,请访问Session._runner.friendly_name
import nox
@nox.session(python=['3.6', '3.7', '3.8', '3.9'])
def test(session):
session.install('.')
session.install('pytest', 'pytest-cov')
session.env['COVERAGE_FILE'] = f'.coverage.{session._runner.friendly_name}'
session.run('python', '-m', 'pytest', '--cov', 'tests/')因为这需要访问私有属性,所以除了没有文档记录之外,它还应该被认为是不稳定的。
发布于 2021-05-01 18:51:44
这是作为Session.name的recently implemented,并将包含在下一个版本中。
import nox
@nox.session(python=['3.6', '3.7', '3.8', '3.9'])
def test(session):
session.install('.')
session.install('pytest', 'pytest-cov')
session.env['COVERAGE_FILE'] = f'.coverage.{session.name}'
session.run('python', '-m', 'pytest', '--cov', 'tests/')完全公开:我写了添加这个的公关。
https://stackoverflow.com/questions/66170792
复制相似问题