Skip to content

Fix unit test to use temp path instead of writing files locally - #1449

Open
andrewelamb wants to merge 3 commits into
developfrom
fix_unit_tests
Open

Fix unit test to use temp path instead of writing files locally#1449
andrewelamb wants to merge 3 commits into
developfrom
fix_unit_tests

Conversation

@andrewelamb

@andrewelamb andrewelamb commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Problem:

Running the unit test suite left two artifacts behind in the current working directory that were never cleaned up: a manifest.csv file and a folder_name/ directory (containing its own manifest.csv).

  • Reproduced by running pytest tests/unit from the repo root and checking git status afterwards.
  • The source is test_sync_from_synapse_manifest_is_suppress in tests/unit/synapseutils/unit_test_synapseutils_sync.py, which calls syncFromSynapse with path="./".

Solution:

Changed the test to use pytest's tmp_path fixture instead of "./", so any files written by the sync land in a pytest-managed temp directory instead of the repo root:

  • Added a tmp_path: Path parameter to the test signature (with the pathlib.Path import).
  • Passed path=str(tmp_path) to syncFromSynapse and updated the two download_location assertions to match.

Testing:

  • Ran the affected test from the repo root: pytest tests/unit/synapseutils/unit_test_synapseutils_sync.py::test_sync_from_synapse_manifest_is_suppress — passes.
  • Confirmed with git status that no manifest.csv or folder_name/ artifacts are created in the working directory after the run.

@andrewelamb
andrewelamb requested a review from a team as a code owner August 20, 2026 15:37

@thomasyu888 thomasyu888 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 LGTM! I'm going to pre-approve, but I think it would be good to have another team member approve.

I also re-triggered the fails jobs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants