-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Tests should be self-contained and repeatable #259
Comments
See also Issue #181 |
I wonder if we should annotate all the expensive test using nose plubing attrib - eg: from nose.plugins.attrib import attr
@attr(speed='slow')
def test_download_intahwebs():
pass This would helpfully mark all the tests we need to migrate and the difference between testing styles would be easily discoverable to new contributors. |
Just to give some basic measurements
|
Annotating using that plugin seems fine to me. In particular, I'd like to annotate (and then eliminate) the ones that access external network resources. Slowness is related, but not the same - simply installing stuff can be slow enough to make end-to-end functional tests pretty slow even if they never access the network (this is largely why the network-caching stuff from last summer wasn't nearly as successful in reducing test runtimes as we'd hoped). But yeah - annotating slow tests is fine too. |
Now we'd have to use pytest markers instead of nose ones, but that's a small change. I remember now that pytest-httpbin forks a process with httpbin, a simple Flask app, so I don't see why we couldn't do the same to create local mocks of PyPI, github, bitbucket, launchpad, ... |
But we'd still need to have versions that hit the real PyPI, GitHub, etc. and run them every now and then, to make sure that we're not testing against mocks that no longer reflect reality. |
A bunch of PRs were just merged that address some of this at least for
|
pip's test suite is certainly repeatable now. We don't have complete network isolation, but I reckon that's OK. Closing this out on the basis that having tests depend on the network is OK; as long as it's clearly reflected. |
Tests that depend on external things (PyPI, github, bitbucket, launchpad) are brittle and prone to failure. Our current caching strategy for those external dependencies helps with the speed problem (some; not as much as one would hope), but makes the fragility even worse - it introduces an extra layer of complexity and of things that might change from one test run to the next (i.e. some broken test corrupting the cache causes the next cached run to fail). These are all real problems that wasted my time during the Py3k porting work.
I want to convert all of pip's tests to be all self-contained all the time and fully repeatable - no external dependencies. That means our tests create any repositories that they need locally as part of test setup, and we use hg serve, bzr serve, git-web etc if needed to simulate fetching across the network. Similarly for PyPI.
We could leave in place a test script that does some actual tests with remote repos and PyPI, that wouldn't be run as part of the normal test suite or by CI, but could be used as a real-world sanity check.
The text was updated successfully, but these errors were encountered: