mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
The code are wrapped due to us using line-length=79 before, but now some of the code can easily fit in 88 chars. The formatter did not change this automatically when we changed line-length, because of magic trailing commas that gets added when they turn into multiple lines. Black/ruff wrapping them in parens and splitting them into multiple lines was making it difficult to read.
25 lines
543 B
Python
25 lines
543 B
Python
import pytest
|
|
|
|
COPY_SCRIPT = """
|
|
import os
|
|
import shutil
|
|
import sys
|
|
|
|
if os.path.isfile(sys.argv[1]):
|
|
shutil.copyfile(sys.argv[1], sys.argv[2])
|
|
else:
|
|
shutil.copytree(sys.argv[1], sys.argv[2])
|
|
""".replace("\r\n", "\n")
|
|
|
|
|
|
def _add_script(tmp_dir, path, contents=""):
|
|
script, *_ = tmp_dir.gen(path, contents.encode("utf-8"))
|
|
if hasattr(tmp_dir, "scm"):
|
|
tmp_dir.scm_add(path, commit=f"add {path}")
|
|
return script.fs_path
|
|
|
|
|
|
@pytest.fixture
|
|
def copy_script(tmp_dir):
|
|
return _add_script(tmp_dir, "copy.py", COPY_SCRIPT)
|