How do I get the name of the currently running nox session? For example, to use the name to customize a coverage file:
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/')
This was recently implemented as
Session.name
and will be included in the next release.Full disclosure: I wrote the PR that added this.