python - 获取当前 nox 会话的名称
问题描述
如何获取当前运行的 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/')
解决方案
此信息可在以下网址获得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/')
因为这需要访问私有属性,所以除了未记录之外,它还应该被认为是不稳定的。
推荐阅读
- css - 如何更改标签的css?
- javascript - Javascript将对象中的嵌套函数绑定到根对象
- javascript - 使用 Google Auth 登录 React Redux 问题
- sql-server-2008 - 合并两个具有非等价列的表
- c# - 将json字符串保存到txt文件时的序列化问题
- ios - Firebase 获取重复数据
- c# - Box collider里面的Box collider会影响游戏性能吗?
- powershell - 从powershell类中的方法内返回多个变量
- c# - 我应该如何用科学计数法(+301)解析一个非常大的数字?
- javascript - 导出为默认的多个导入模块