Skip to content

Add functionality similar to pytest.mark #339

@miloszbednarzak

Description

@miloszbednarzak

How would this feature be useful?
It can simplify filtering specific sessions to be run. It can simplify writing long commands like nox -s tests, lint, type, .... It can also extend the functionality of nox.options.sessions.

Describe the solution you'd like
I have two ideas how this can be done.
Basically it can be run by:
nox -m [mark-name] if feature called "Marks" as in pytest,
nox -t [tag-name] if feature called "Tags".
And nox will run only sessions annotated by this mark/tag.

1st option
In noxfile.py it can be configured either by:

@nox.mark("mark_name")
@nox.session()
def ...

or

@nox.tag("tag_name")
@nox.tag("other_tag_name")
@nox.session()
def ...

2nd option

nox.options.tags = {
    "default": ["session1", "session2"],  # this might replace `nox.options.sessions`
    "tag1": ["session1", "session4"],
    "tag2": ["session2", "session3"],
    etc.
}

Personally I prefer the 2nd option, I think it makes it more clear and concise.
And also I prefer "Tags" over "Marks" name, IMO "Tags" more precisely describe what it is. On the other hand, "Marks" might be known for those who use pytest.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions