Skip to content

[Bug]: Path tests failing on Windows #616

Closed
@CyanVoxel

Description

@CyanVoxel

Checklist

  • I am using an up-to-date version.
  • I have read the documentation.
  • I have searched existing issues.

TagStudio Version

main branch (v9.5.0)

Operating System & Version

Windows 10 22H2

Description

Two path tests (test_evaluate_path_last_lib_present, test_save_windows_path) always fail when run on Windows.

Expected Behavior

Tests should pass on all platforms.

Steps to Reproduce

  1. Run test_evaluate_path_last_lib_present and test_save_windows_path tests on Windows
  2. Observe failed tests in summary

Logs

================================================= FAILURES ================================================== 
____________________________________ test_evaluate_path_last_lib_present ____________________________________ 

    def test_evaluate_path_last_lib_present():
        # Given
        settings = QSettings()
        with TemporaryDirectory() as tmpdir:
            settings.setValue(SettingItems.LAST_LIBRARY, tmpdir)
            makedirs(Path(tmpdir) / TS_FOLDER_NAME)
            driver = TestDriver(settings)

            # When
            result = driver.evaluate_path(None)

            # Then
>           assert result == LibraryStatus(success=True, library_path=Path(tmpdir))
E           AssertionError: assert LibraryStatus... message=None) == LibraryStatus... message=None)
E
E             Omitting 2 identical items, use -vv to show
E             Differing attributes:
E             ['library_path']
E
E             Drill down into differing attribute library_path:
E               library_path: None != WindowsPath('C:/Users/Faceboji/AppData/Local/Temp/tmpvay1w9wy')

tagstudio\tests\test_driver.py:66: AssertionError
__________________________________________ test_save_windows_path ___________________________________________ 

library = <src.core.library.alchemy.library.Library object at 0x00000297648DB6E0>
generate_tag = <function generate_tag.<locals>.inner at 0x000002975EA6B7E0>

    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"
E       AssertionError: assert 'foo\\bar.txt' == 'foo/bar.txt'
E
E         - foo/bar.txt
E         ?    ^
E         + foo\bar.txt
E         ?    ^

tagstudio\tests\test_library.py:292: AssertionError
------------------------------------------- Captured stdout setup ------------------------------------------- 
2024-11-29 16:08:40 [info     ] opening library                connection_string=sqlite:///:memory: library_dir=WindowsPath('/dev/null')
2024-11-29 16:08:40 [info     ] creating db tables
------------------------------------------- Captured stdout call -------------------------------------------- 
2024-11-29 16:08:40 [info     ] tag added to field             entry_id=3 field=<src.core.library.alchemy.fields.TagBoxField object at 0x000002976484AE40> tag=<Tag ID: 1003 Name: win_path>
2024-11-29 16:08:40 [info     ] searching library              filter=FilterState(page_index=0, page_size=500, search_mode=<SearchMode.AND: 0>, tag='win_path', tag_id=None, id=None, path=None, name=None, filetype=None, mediatype=None, query=None) query_full=SELECT entries.id, entries.folder_id, entries.path, entries.suffix      
FROM entries JOIN tag_box_fields ON entries.id = tag_box_fields.entry_id JOIN tag_fields AS tag_fields_1 ON tag_box_fields.id = tag_fields_1.field_id JOIN tags ON tags.id = tag_fields_1.tag_id LEFT OUTER JOIN tag_aliases ON tags.id = tag_aliases.tag_id LEFT OUTER JOIN (tag_subtags AS tag_subtags_1 JOIN tags AS tags_1 ON tags_1.id = tag_subtags_1.child_id) ON tags.id = tag_subtags_1.parent_id
WHERE (lower(tags.name) LIKE lower('win_path') OR lower(tags.shorthand) LIKE lower('win_path') OR lower(tag_aliases.name) LIKE lower('win_path') OR lower(tags_1.name) LIKE lower('win_path')) AND (entries.suffix NOT IN ('.json', '.xmp', '.aae'))
 LIMIT 500 OFFSET 0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority: MediumAn issue that shouldn't be be saved for lastType: BugSomething isn't working as intendedType: TestsTests or testing related

    Type

    No type

    Projects

    Status

    ✅ Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions