Skip to content

Commit

Permalink
fix: support parametrized sessions with modern parametrization
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Sep 10, 2024
1 parent 067f841 commit 73b3b85
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions nox/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def add_dependencies(self) -> None:
~nox._resolver.CycleError: If a dependency cycle is encountered.
"""
sessions_by_id = self.all_sessions_by_signature

# For each session that was parametrized from a list of Pythons, create a fake
# parent session that depends on it.
parent_sessions: set[SessionRunner] = set()
Expand Down
6 changes: 6 additions & 0 deletions nox/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,12 @@ def __init__(
self.result: Result | None = None
self.multi = multi

if getattr(func, "parametrize", None):
self.multi = True

def __repr__(self) -> str:
return f"<SessionRunner {self.name}: {self.signatures!r} {self.multi}>"

@property
def description(self) -> str | None:
doc = self.func.__doc__
Expand Down
16 changes: 16 additions & 0 deletions tests/resources/noxfile_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,19 @@ def s(session):
@nox.session(requires=["r"])
def t(session):
print(session.name)


@nox.parametrize("django", ["1.9", "2.0"])
@nox.session
def u(session, django):
print(session.name)


@nox.session(requires=["u(django='1.9')", "u(django='2.0')"])
def v(session):
print(session.name)


@nox.session(requires=["u"])
def w(session):
print(session.name)

0 comments on commit 73b3b85

Please sign in to comment.