Skip to content

Commit

Permalink
Fix missing shutil copies
Browse files Browse the repository at this point in the history
  • Loading branch information
Neraste committed Jan 28, 2025
1 parent 9da2ab4 commit eed7322
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/dakara_player/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from abc import ABC, abstractmethod
from importlib.resources import contents, path
from pathlib import Path
from shutil import copy

from dakara_base.exceptions import DakaraError

Expand Down Expand Up @@ -196,7 +197,7 @@ def load_font(self, font_file_path, system_font_path_list, user_font_path_list):
font_file_user_path.unlink(missing_ok=True)

# then, if the font is not installed, load by copying it
font_file_path.copy(font_file_user_path)
copy(font_file_path, font_file_user_path)

# register the font
self.fonts_loaded[font_file_name] = font_file_user_path
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_load(
)

@patch.object(Path, "unlink", autospec=True)
@patch.object(Path, "copy", autospec=True)
@patch("dakara_player.font.copy", autospec=True)
@patch.object(Path, "is_symlink", autospec=True)
def test_load_font_system(self, mocked_is_symlink, mocked_copy, mocked_unlink):
"""Test to load one font which is in system directory."""
Expand Down Expand Up @@ -200,7 +200,7 @@ def test_load_font_system(self, mocked_is_symlink, mocked_copy, mocked_unlink):
mocked_copy.assert_not_called()

@patch.object(Path, "unlink", autospec=True)
@patch.object(Path, "copy", autospec=True)
@patch("dakara_player.font.copy", autospec=True)
@patch.object(Path, "is_symlink", autospec=True)
def test_load_font_user(self, mocked_is_symlink, mocked_copy, mocked_unlink):
"""Test to load one font which is in user directory."""
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_load_font_user(self, mocked_is_symlink, mocked_copy, mocked_unlink):
mocked_copy.assert_not_called()

@patch.object(Path, "unlink", autospec=True)
@patch.object(Path, "copy", autospec=True)
@patch("dakara_player.font.copy", autospec=True)
@patch.object(Path, "is_symlink", autospec=True)
def test_load_font_user_link_dead_install(
self,
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_load_font_user_link_dead_install(
mocked_copy.assert_called_once_with("directory/font_file.ttf", font_path)

@patch.object(Path, "unlink", autospec=True)
@patch.object(Path, "copy", autospec=True)
@patch("dakara_player.font.copy", autospec=True)
@patch.object(Path, "is_symlink", autospec=True)
def test_load_font_install(self, mocked_is_symlink, mocked_copy, mocked_unlink):
"""Test to load one font which is not installed."""
Expand Down

0 comments on commit eed7322

Please sign in to comment.