Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Session.name #386

Merged
merged 1 commit into from Feb 14, 2021
Merged

Add Session.name #386

merged 1 commit into from Feb 14, 2021

Conversation

drhagen
Copy link
Contributor

@drhagen drhagen commented Feb 14, 2021

Being able to know what session you are in is useful for a variety of reasons. One of which is to be able to name artifacts in a way that is traceable back to the session, such as with code coverage reports. Right now, the only solution is to dig down to 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/')

This PR exposes that private attribute via a public property:

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/')

Copy link
Collaborator

@stsewd stsewd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@stsewd stsewd merged commit db63783 into wntrblm:main Feb 14, 2021
@theacodes
Copy link
Collaborator

Thank you both for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants