-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
This might entirely class "user error", but I mistyped the pytest launch command and lost my entire source repository, e.g. commits, stashes and WIP branches (most backed up, luckily). The system I was running on only had a small /tmp
available so I wanted to change the path. Unfortunately I left a space in pytest --basetmp= /scratch/tmp .
- this wiped out the entire working directory. It has the same behaviour if you don't provide a path:
mkdir test_folder
cd test_folder
echo -e "def test_a(tmpdir):\n pass" >> test_a.py
pytest --basetmp= .
I note that the argument help says "(warning: this directory is removed if it exists)" but isn't mentioned on https://docs.pytest.org/en/latest/tmpdir.html#the-default-base-temporary-directory - and wouldn't protect against a typo anyway.
Only accepting folders that don't exist or that it's used before (with a breadcrumb file?) seem like A Fix, but changes the way it works and is more complicated. It might be simpler to be slightly safer? Is there any scenario in which allowing this option to be empty for the current working directory makes sense?
Cause looks to be
Lines 31 to 33 in 3d0f3ba
converter=attr.converters.optional( | |
lambda p: Path(os.path.abspath(str(p))) # type: ignore | |
), |
attr.converters.optional
treats an empty string as "Not None" and os.path.abspath
interprets an empty string as cwd.
Pytest 5.4.1.