Skip to content

replace tmpdir with tmp_path#2550

Open
dotlambda wants to merge 1 commit intospotDL:masterfrom
dotlambda:tmp_path
Open

replace tmpdir with tmp_path#2550
dotlambda wants to merge 1 commit intospotDL:masterfrom
dotlambda:tmp_path

Conversation

@dotlambda
Copy link
Contributor

Replace the tmpdir fixture with tmp_path

Description

Related Issue

Motivation and Context

see https://stackoverflow.com/a/36071167

How Has This Been Tested?

Screenshots (if appropriate)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have added tests to cover my changes
  • All new and existing tests passed

@Silverarmor Silverarmor requested a review from Copilot October 27, 2025 22:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR modernizes the test suite by replacing the deprecated tmpdir fixture with the newer tmp_path fixture across all test files. The tmp_path fixture is the recommended approach in pytest as it returns a pathlib.Path object instead of a legacy py.path.local object, providing better type safety and consistency with modern Python path handling.

Key changes:

  • Replaced tmpdir parameter with tmp_path in all test function signatures
  • Updated all references from tmpdir to tmp_path within test function bodies

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/utils/test_metadata.py Updated fixture parameter and internal references in test_embed_metadata
tests/utils/test_m3u.py Updated fixture parameter and internal references in test_create_m3u_file
tests/utils/test_github.py Updated fixture parameter and internal references in test_download_github_dir
tests/utils/test_ffmpeg.py Updated fixture parameter and internal references in test_download_ffmpeg and test_convert
tests/utils/test_config.py Updated fixture parameter and internal references in setup fixture
tests/utils/test_archive.py Updated fixture parameter and internal references in test_load_archive
tests/test_init.py Updated fixture parameter and internal references in test_download
tests/console/test_entry_point.py Updated fixture parameter and internal references in test_download_song and test_preload_song

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

playlist = Playlist.from_url(PLAYLIST)
create_m3u_file("test.m3u", playlist.songs, "", "mp3")
assert tmpdir.join("test.m3u").isfile() is True
assert tmp_path.join("test.m3u").isfile() is True
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

tmp_path is a pathlib.Path object and does not have a join() method. Use the / operator instead: assert (tmp_path / "test.m3u").is_file() is True. Also note that pathlib.Path uses is_file() instead of isfile().

Suggested change
assert tmp_path.join("test.m3u").isfile() is True
assert (tmp_path / "test.m3u").is_file() is True

Copilot uses AI. Check for mistakes.
Comment on lines +52 to 54
download_dir = tmp_path.listdir()[0]
assert download_dir.isdir() is True
assert download_dir.join("index.html").isfile() is True
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

tmp_path is a pathlib.Path object and does not have listdir(), isdir(), or join() methods. Use list(tmp_path.iterdir()) to list contents, is_dir() to check if it's a directory, and the / operator for path joining: download_dir = list(tmp_path.iterdir())[0], assert download_dir.is_dir() is True, and assert (download_dir / "index.html").is_file() is True.

Suggested change
download_dir = tmp_path.listdir()[0]
assert download_dir.isdir() is True
assert download_dir.join("index.html").isfile() is True
download_dir = list(tmp_path.iterdir())[0]
assert download_dir.is_dir() is True
assert (download_dir / "index.html").is_file() is True

Copilot uses AI. Check for mistakes.
archive1 = Archive(["a", "b", "c"])
assert archive1.save("archive.txt") is True
assert tmpdir.join("archive.txt").isfile() is True
assert tmp_path.join("archive.txt").isfile() is True
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

tmp_path is a pathlib.Path object and does not have a join() method. Use the / operator instead: assert (tmp_path / "archive.txt").is_file() is True. Also note that pathlib.Path uses is_file() instead of isfile().

Suggested change
assert tmp_path.join("archive.txt").isfile() is True
assert (tmp_path / "archive.txt").is_file() is True

Copilot uses AI. Check for mistakes.
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