Skip to content

Stop tests from leaving files in the system temporary directory - #968

Merged
caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:fix-test-temp-file-leaks
Nov 24, 2026
Merged

caglarpir merged 1 commit into
mapillary:mainfrom
caglarpir:fix-test-temp-file-leaks

Conversation

@caglarpir

Copy link
Copy Markdown
Contributor

Every test run left files in the system temporary directory. With TMPDIR set to an empty directory, the unit and integration tests left 153 entries in it on main:

  • 149 tmpXXXXXXXX.json: run_process_for_descs created its description file with delete=False on every platform, but removed it only on Windows.
  • 3 tmpXXXXXXXX.gpx: three GPX parsing tests wrote their GPX file with delete=False and never removed it.
  • mapillary_public_uploads/ (42 files): the TestImageSequenceUploader tests upload in dry-run mode without setting MAPILLARY_UPLOAD_ENDPOINT, so the uploads went to the default directory in the temporary directory.

The fixture now writes the description file in a temporary directory that is removed afterwards, so it no longer keeps a file open while the command writes to it (the Windows problem in #503). The GPX tests write to tmp_path, and the uploader tests upload to a directory in tmp_path.

With this change the same run leaves nothing besides pytest's own pytest-of-<user> directory, and all tests still pass.

Every test run left files in the system temporary directory:

- run_process_for_descs created its description file with delete=False
  on every platform, but removed it only on Windows. So every
  integration test that calls it left a tmpXXXXXXXX.json behind.
- Three GPX parsing tests wrote their GPX file with delete=False and
  never removed it.
- The TestImageSequenceUploader tests upload in dry-run mode without
  setting MAPILLARY_UPLOAD_ENDPOINT, so they uploaded to the default
  mapillary_public_uploads directory in the temporary directory.

The fixture now writes the description file in a temporary directory
that is removed afterwards, the GPX tests write to tmp_path, and the
uploader tests upload to a directory in tmp_path.
@meta-cla meta-cla Bot added the cla signed label Nov 24, 2026
@caglarpir
caglarpir merged commit e191859 into mapillary:main Nov 24, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant