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
Unittest to pytest: moved few unittest tests to pytest #6379
Conversation
tests/func/test_scm.py
Outdated
tmp_dir.gen({"foo": "foo"}) | ||
scm.add(["foo"]) | ||
scm.commit("add") | ||
assert "foo" in Repo(tmp_dir).git.ls_files() |
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.
How about this one.
scm.is_tracked("foo")
instead of
assert "foo" in Repo(tmp_dir).git.ls_files()
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've replaced ls_files
with is_tracked
. But I'm not sure if test_commit
is really needed because it seems that test_is_tracked
fully covers test_commit
case.
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.
So, the reason that this did not use is_tracked
before is that is_tracked
is still using our SCM class, and the tests for is_tracked
itself also depends on the assumption that scm.commit
works (so we want to test scm.commit
independently of is_tracked
.
To verify that scm.commit
works, we were testing it directly using CLI git before (the git.ls_files
call spawns an actual CLI git ls-files
call via gitpython).
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.
ok. Now test_commit
makes sense.
tests/func/test_init.py
Outdated
self._test_init() | ||
def test_api_init(scm): | ||
DvcRepo.init().close() | ||
_check_dirs() |
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.
Just the check for isdir
should be enough, so I think it'd be more clearer if we get rid of _check_dirs
and replace them with os.path.isdir(repo.DVC_DIR)
. 1 less indirection.
Co-authored-by: Peter Rowlands (변기호) <peter@pmrowla.com>
Thank you, @nik123 ! 🙏 |
Part of #1819
❗ I have followed the Contributing to DVC checklist.
📖 If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
PR doesn't require documentation updates.