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
TST: protocols: Don't assume GitRepo runs a callable #3145
Conversation
I guess it was done so that we also check that we can protocol those GitRepo calls, which were our main calls of interest. So the "assumption" was on purpose, may be we could have just left a comment for the reader that it was intentional? So in principle we could/should've left it as such. But the fact of life is that we haven't developed more (e.g. we had an idea to protocol execution times) or used those protocols extensively, besides me using the one for protocolling interactions with git-annex, so pragmatically we could no longer assume that and change the test/code accordingly. OR introduced by revolution code could make use of this facility? |
OK, I'll update my commit message so that I don't mischaracterize the intention, but ...
While a comment wouldn't have hurt, I think the current testing gets things backwards (which maybe shouldn't count for much since I didn't even know protocols existed until last week :). test_protocols.py should be about testing the module, not about testing that some other class adheres to a callable rather than an external command. GitRepo uses Runner (and thus protocols), not the other way around. Plus, testing initialization of GitRepo doesn't do a thorough job of testing that the commands that GitRepo passes through the runner follow the expected "callable vs external"; it just tests the one runner call in _create_empty_repo. So, if we want to enforce that a particular form, callable or external command, is used for a particular GitRepo method, I think we should document that expectation in the GitRepo class and have a test in tests_gitrepo.py that check this. (And the same would apply to AnnexRepo methods.)
Sorry, I can't make out what your point is here, and how it relates to whether _create_empty_repo() passes a callable or external command to the runner. |
My point was that I am ok if we were to drop that testing of being able to protocol GitRepo calls if that would not interfere with protocoling interactions with git annex |
I'm lost. Is there something you're doing with protocols now that won't work when |
protocol.py distinguishes between external commands and callables. To test the "callable" case, we create a GitRepo, assuming that this will lead to gitpy.Repo.init() being executed through the runner. But in -revolution, RevolutionGitRepo overrides _create_empty_repo() and uses the external command 'git init' as of 8b9d65a (ENH: Expose git-init options, create without GitPython, 2018-10-29). As a result, these protocol tests fail if we substitute RevolutionGitRepo for GitRepo. Use os.mkdir to prepare for the absorption of RevolutionGitRepo into GitRepo.
The last commit dropped the GitRepo bits from test_protocols.py, which means we're no longer testing that things seem to get wired up correctly when a custom runner with a non-default protocol is passed to GitRunner. Add a test to test_gitrepo.py to make up for that.
f8f7555
to
2f2fb30
Compare
Codecov Report
@@ Coverage Diff @@
## master #3145 +/- ##
==========================================
- Coverage 90.74% 90.51% -0.23%
==========================================
Files 248 248
Lines 32714 32715 +1
==========================================
- Hits 29686 29612 -74
- Misses 3028 3103 +75
Continue to review full report at Codecov.
|
1 similar comment
Codecov Report
@@ Coverage Diff @@
## master #3145 +/- ##
==========================================
- Coverage 90.74% 90.51% -0.23%
==========================================
Files 248 248
Lines 32714 32715 +1
==========================================
- Hits 29686 29612 -74
- Misses 3028 3103 +75
Continue to review full report at Codecov.
|
I've tweaked the commit message and added another commit with a new test, Range-diff:
|
protocols.py distinguishes between external commands and callables.
To test the "callable" case, we create a GitRepo, assuming that this
will lead to gitpy.Repo.init() being executed through the runner.
This is problematic because it depends on internal details of GitRepo
and a reader has to dig into the GitRepo class to understand why we
expect a callable to be used.
And with -revolution, those internal details change. RevolutionGitRepo
overrides _create_empty_repo() and uses the external command 'git
init' as of 8b9d65a (ENH: Expose git-init options, create without
GitPython, 2018-10-29). As a result, these protocol tests fail if we
substitute RevolutionGitRepo for GitRepo.
Use os.mkdir as the callable to simplify these tests and prepare for
the absorption of RevolutionGitRepo into GitRepo.