Files
dvc/dvc/testing/scripts.py
T
skshetry 9a1bcd7f1d nit: fit statement/expr in the same line instead of hanging (#10267)
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.
2024-01-30 18:23:04 +05:45

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)