-
-
Notifications
You must be signed in to change notification settings - Fork 605
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 option for specifying environment variable with concurrency slot #10297
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,13 @@ def register_options(cls, register): | |
advanced=True, | ||
help="The format of the generated XML file. See https://docs.pytest.org/en/latest/reference.html#confval-junit_family.", | ||
) | ||
register( | ||
"--execution-slot-var", | ||
type=str, | ||
default="", | ||
advanced=True, | ||
help="If a non-empty string, the process execution slot id (an integer) will be exposed to tests under this environment variable name.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think this might be longer than 100 characters. Appreciated if you can split this up into multiple lines. I like the style of wrapping in parentheses: help=(
"blah blah"
"blah"
) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wouldn't this be caught by the linter if it was? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. We turned off the check for Flake8 because it doesn't work well with Black. Black is careful when formatting strings and doesn't touch them generally. |
||
) | ||
|
||
def get_requirement_strings(self) -> Tuple[str, ...]: | ||
"""Returns a tuple of requirements-style strings for Pytest and Pytest plugins.""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ class Process: | |
timeout_seconds: Union[int, float] | ||
jdk_home: Optional[str] | ||
is_nailgunnable: bool | ||
execution_slot_variable: str | ||
|
||
def __init__( | ||
self, | ||
|
@@ -48,6 +49,7 @@ def __init__( | |
timeout_seconds: Optional[Union[int, float]] = None, | ||
jdk_home: Optional[str] = None, | ||
is_nailgunnable: bool = False, | ||
execution_slot_variable: str = "", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to make this |
||
) -> None: | ||
"""Request to run a subprocess, similar to subprocess.Popen. | ||
|
||
|
@@ -86,6 +88,7 @@ def __init__( | |
self.timeout_seconds = timeout_seconds if timeout_seconds and timeout_seconds > 0 else -1 | ||
self.jdk_home = jdk_home | ||
self.is_nailgunnable = is_nailgunnable | ||
self.execution_slot_variable = execution_slot_variable | ||
|
||
|
||
@frozen_after_init | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be a bit cleaner for this to default to
None
(Optional[str]
) here and in theProcess
constructor, even if inside ofProcess
it gets converted into the empty string.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the options
type
kwarg know how to interpret modern Pythontyping
type annotations?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. You keep
type=str
and setdefault=None
. The type will end up beingOptional[str]
.