File: test_gen.py

package info (click to toggle)
python-refurb 1.27.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,700 kB
  • sloc: python: 9,468; makefile: 40; sh: 6
file content (26 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from pathlib import Path
from unittest.mock import patch

from refurb.gen import folders_needing_init_file


def test_folder_not_in_cwd_is_ignored():
    with patch("pathlib.Path.cwd", lambda: Path("/some/random/path")):
        assert folders_needing_init_file(Path("./some/path")) == []


def test_relative_path_works():
    assert folders_needing_init_file(Path("./a/b/c")) == [
        Path.cwd() / "a" / "b" / "c",
        Path.cwd() / "a" / "b",
        Path.cwd() / "a",
    ]


def test_absolute_path_works():
    assert folders_needing_init_file(Path.cwd() / "a" / "b" / "c" / "d") == [
        Path.cwd() / "a" / "b" / "c" / "d",
        Path.cwd() / "a" / "b" / "c",
        Path.cwd() / "a" / "b",
        Path.cwd() / "a",
    ]