-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add: test: convert to dir helpers 1 #2898
Conversation
tests/func/test_add.py
Outdated
@@ -168,17 +168,19 @@ def test(self): | |||
self.assertTrue(stages[0] is not None) | |||
|
|||
|
|||
def test_add_file_in_dir(repo_dir, dvc_repo): | |||
stage, = dvc_repo.add(repo_dir.DATA_SUB) | |||
def test_add_file_in_dir(dvc, tmp_dir): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order doesn't matter to python, but it matters to reader. Let's list fixtures in the same order everywhere: tmp_dir
, scm
(if used), dvc
. This is chronological: temp dir is created, then git init, then dvc init.
new_file = os.path.join(repo_dir.DATA_DIR, "new_file") | ||
def test_readding_dir_should_not_unprotect_all(dvc, tmp_dir, mocker): | ||
tmp_dir.gen({"dir": {"data": "data"}}) | ||
dvc.cache.local.cache_types = ["symlink"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add an empty line after tmp_dir.gen()
, up to you.
tests/func/test_add.py
Outdated
|
||
repo_dir.create(new_file, "new_content") | ||
dvc.add("dir") | ||
tmp_dir.gen({"dir": {"new_file": "new_file_content"}}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other option:
tmp_dir.get("dir/new_file", "new_file_contents")
Less punctuation.
tests/func/test_add.py
Outdated
shutil.copy(repo_dir.BAR, repo_dir.FOO) | ||
tmp_dir.gen({"foo": "foo", "bar": "bar"}) | ||
dvc.add("foo") | ||
dvc.add("bar") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace 3 lines with:
dvc.add("bar") | |
tmp_dir.dvc_gen({"foo": "foo", "bar": "bar"}) |
test_add_file_in_dir test_readding_dir_should_not_unprotect_all test_should_not_checkout_when_adding_cached_copy
test_add_file_in_dir
test_readding_dir_should_not_unprotect_all
test_should_not_checkout_when_adding_cached_copy
β Have you followed the guidelines in the Contributing to DVC list?
π Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
β Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addressed. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. π
related to #2896
Started doing whole
test_add
, but iterations will probably be faster in batches, also reviewing 3 changed tests is easier than 20.