Skip to content
Merged
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
17 changes: 17 additions & 0 deletions tests/unit/utils/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import filecmp
import re
import os

import pytest
Expand All @@ -9,6 +10,7 @@
from dvc.utils import fix_env
from dvc.utils import makedirs
from dvc.utils import to_chunks
from dvc.utils import tmp_fname
from tests.basic_env import TestDir


Expand Down Expand Up @@ -122,3 +124,18 @@ def test_makedirs(repo_dir):

makedirs(path_info)
assert os.path.isdir(path_info.fspath)


def test_tmp_fname():
file_path = os.path.join("path", "to", "file")
file_path_info = PathInfo(file_path)

def pattern(path):
return r"^" + re.escape(path) + r"\.[a-z0-9]{22}\.tmp$"

assert re.search(pattern(file_path), tmp_fname(file_path), re.IGNORECASE)
assert re.search(
pattern(file_path_info.fspath),
tmp_fname(file_path_info),
re.IGNORECASE,
)