File: test_utils.py

package info (click to toggle)
f3d 3.2.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,668 kB
  • sloc: cpp: 99,109; python: 811; sh: 342; xml: 238; java: 101; javascript: 95; makefile: 25
file content (32 lines) | stat: -rw-r--r-- 861 bytes parent folder | download
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
27
28
29
30
31
32
import f3d
import os

from pathlib import Path


def test_text_distance():
    assert f3d.Utils.text_distance("modle", "model") == 2


def test_collapse_path():
    assert f3d.Utils.collapse_path("/folder/../file.ext", ".") == Path("/file.ext")


def test_glob_to_regex():
    assert f3d.Utils.glob_to_regex("*vt?") == ".*vt."
    assert f3d.Utils.glob_to_regex("**/*vt?") == "(?:[^/]*(?:/|$))*[^/]*vt[^/]"
    assert (
        f3d.Utils.glob_to_regex(glob="**\\\\*vt?", path_separator="\\")
        == "(?:[^\\\\]*(?:\\\\|$))*[^\\\\]*vt[^\\\\]"
    )


def test_get_env():
    assert f3d.Utils.get_env("F3D_TEST_ENV_EMPTY") == None


def test_get_know_folder():
    if os.name == "nt":
        assert f3d.Utils.get_known_folder(f3d.Utils.KnownFolder.PICTURES) != None
    else:
        assert f3d.Utils.get_known_folder(f3d.Utils.KnownFolder.PICTURES) == None