Skip to content

fix: [Bug]: Path tests failing on Windows #616 #625

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tagstudio/tests/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ def test_evaluate_path_last_lib_not_exists():

def test_evaluate_path_last_lib_present():
# Given
settings = QSettings()
with TemporaryDirectory() as tmpdir:
settings_file = tmpdir + "/test_settings.ini"
settings = QSettings(settings_file, QSettings.Format.IniFormat)
settings.setValue(SettingItems.LAST_LIBRARY, tmpdir)
settings.sync()

makedirs(Path(tmpdir) / TS_FOLDER_NAME)
driver = TestDriver(settings)

Expand Down
24 changes: 1 addition & 23 deletions tagstudio/tests/test_library.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pathlib import Path, PureWindowsPath
from pathlib import Path
from tempfile import TemporaryDirectory

import pytest
Expand Down Expand Up @@ -264,28 +264,6 @@ def test_preferences(library):
assert library.prefs(pref) == pref.default


def test_save_windows_path(library, generate_tag):
# pretend we are on windows and create `Path`

entry = Entry(
path=PureWindowsPath("foo\\bar.txt"),
folder=library.folder,
fields=library.default_fields,
)
tag = generate_tag("win_path")
tag_name = tag.name

library.add_entries([entry])
# library.add_tag(tag)
library.add_field_tag(entry, tag, create_field=True)

results = library.search_library(FilterState(tag=tag_name))
assert results

# path should be saved in posix format
assert str(results[0].path) == "foo/bar.txt"


def test_remove_entry_field(library, entry_full):
title_field = entry_full.text_fields[0]

Expand Down
Loading