Skip to content

Commit

Permalink
Fix test error on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
realshouzy committed Jan 5, 2024
1 parent 0908354 commit c39db81
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 9 additions & 3 deletions tests/args_handling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
import json
import platform
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Final

import pytest

Expand Down Expand Up @@ -33,6 +33,11 @@

from watchdog.observers.api import BaseObserver

if platform.system() == "Windows":
from pathlib import Path # actually import Path when on Windows

DRIVE: Final[str] = Path().resolve().drive


@pytest.mark.skipif(
platform.system() != "Windows",
Expand Down Expand Up @@ -514,7 +519,8 @@ def test_handle_read_args_all_configs_windows(
assert exit_code == 0

assert (
capsys.readouterr().out == ".txt: C:\\path\\to\\txt\n.pdf: C:\\path\\to\\pdf\n"
capsys.readouterr().out
== f".txt: {DRIVE}\\path\\to\\txt\n.pdf: {DRIVE}\\path\\to\\pdf\n"
)

assert (
Expand Down Expand Up @@ -569,7 +575,7 @@ def test_handle_read_args_selected_configs_windows(
exit_code: int = handle_read_args(args)
assert exit_code == 0

assert capsys.readouterr().out == ".pdf: C:\\path\\to\\pdf\n"
assert capsys.readouterr().out == f".pdf: {DRIVE}\\path\\to\\pdf\n"

assert (
"auto_file_sorter.args_handling",
Expand Down
8 changes: 6 additions & 2 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

import platform
from pathlib import Path
from typing import Final

import pytest

from auto_file_sorter.utils import resolved_path_from_str

if platform.system() == "Windows":
DRIVE: Final[str] = Path().resolve().drive

# pylint: disable=C0116


Expand All @@ -20,12 +24,12 @@
(
pytest.param(
"/path/to/some/file.txt",
Path("C:/path/to/some/file.txt"),
Path(f"{DRIVE}/path/to/some/file.txt"),
id="regular_str",
),
pytest.param(
" /path/to/some/file.txt ",
Path("C:/path/to/some/file.txt"),
Path(f"{DRIVE}/path/to/some/file.txt"),
id="trailing_whitespaces_str",
),
),
Expand Down

0 comments on commit c39db81

Please sign in to comment.