diff --git a/changelog/13091.doc.rst b/changelog/13091.doc.rst new file mode 100644 index 00000000000..2bfd8c1d523 --- /dev/null +++ b/changelog/13091.doc.rst @@ -0,0 +1 @@ +Added Sphinx-compatible docstrings and inline comments for basetemp function in `pytest/src/_pytest/main.py` diff --git a/src/_pytest/main.py b/src/_pytest/main.py index dac084b553a..5f9683eb19a 100644 --- a/src/_pytest/main.py +++ b/src/_pytest/main.py @@ -249,6 +249,18 @@ def pytest_addoption(parser: Parser) -> None: def validate_basetemp(path: str) -> str: + """ + Validate the provided `basetemp` path to ensure it is not empty, + the current working directory (cwd), or any ancestor of the cwd. + Returns the validated basetemp path. + Raises argparse.ArgumentTypeError in 3 cases: + 1) if the path is empty; + 2) if it is the cwd; + 3) if it is an ancestor of the cwd. + + + param: path (str): The basetemp path. + """ # GH 7119 msg = "basetemp must not be empty, the current working directory or any parent directory of it"