question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

data loss with mistyped --basetemp

See original GitHub issue

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 https://github.com/pytest-dev/pytest/blob/3d0f3baa2bb89257dfff25ae6ebabd565287240e/src/_pytest/tmpdir.py#L31-L33 where attr.converters.optional treats an empty string as “Not None” and os.path.abspath interprets an empty string as cwd.

Pytest 5.4.1.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
RonnyPfannschmidtcommented, May 2, 2020

Actually it should error

0reactions
nicoddemuscommented, Jun 9, 2020

Indeed @pangloss, thanks for the ping! We are still in the process of reviewing everything for 6.0, and indeed this is a serious issue.

The PR has now been merged. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

User's Guide to Parssim1: The Parallel Subsurface Simulator ...
to remove lines or ends of lines from a data file, without actually losing the information. (Note that. '#' is an ordinary character...
Read more >
BroodMinder User Guide | Meyer Bees
Basic operation for a new user. • First Time o Download BroodMinder-Bees from your app store o Start the app and enter (or...
Read more >
Changelog — pytest documentation
... --basetemp argument is empty, is the current working directory or is one of the parent directories. This is done to protect against...
Read more >
FUG1010 IP 65 NEMA 7 Compact ... - Gilson Engineering Sales
Replace the PGEN menu cell description and set up procedure in the Data ... ence pressure and temperature (referred to as base press...
Read more >
Request for Quotations number SES60017Q0078 The Am
TITLE (Typo or print). ~REA CODE ... (2) a complete set of record shop drawings, product data, samples and other ... Base Temp....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found