8000 Tests: allow running tests without internet with a `--skip-tests-requiring-internet` switch by KostyaEsmukov · Pull Request #413 · geopy/geopy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Tests: allow running tests without internet with a --skip-tests-requiring-internet switch #413

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

Merged
merged 1 commit into from
Jun 21, 2020

Conversation

KostyaEsmukov
Copy link
Member

Geocoders tests currently rely on the Internet presence to make actual queries to the geocoding services.

This is inconvenient in the following ways:

  • The network requests make the tests slow
  • Network requests spend quotas, making it harder to use for TDD
  • The test suite cannot be easily run in an environment without Internet access
  • Networking issues make the test runs flaky, which is unwanted for downstream package maintainers.

One solution would be to record actual requests (see #203) and replay them in tests instead of making actual requests. There are two problems with this solution:

  1. Some services disallow storing responses in their ToS
  2. The recorded responses would slowly decay, making maintenance more costly.

Another approach (which is implemented here) is to add an option (--skip-tests-requiring-internet) to the test suite which skips tests requiring network. The test coverage would definitely be lower than the usual runs, however, it is still useful to quickly run a subset of tests to verify that things are not completely broken.

--skip-tests-requiring-internet works by raising pytest.skip at the moment of the first network request in a test. So the code preparing the request is actually getting executed, although it is not validated.

Usage:

python -m pytest --skip-tests-requiring-internet
<...>
==== 302 passed, 295 skipped, 2 xfailed, 1 warning in 8.84s =====

…iring-internet` switch

This might be useful for downstream package maintainers to run tests
of the built package.

Also it is now used in CI where it would help to avoid spending geocoders
quota for test runs which are doomed to failure.

Usage:

    python -m pytest --skip-tests-requiring-internet
@KostyaEsmukov KostyaEsmukov added this to the 1.23 milestone Jun 21, 2020
@KostyaEsmukov KostyaEsmukov merged commit a90570c into master Jun 21, 2020
@KostyaEsmukov KostyaEsmukov deleted the feature/skip-tests-requiring-internet branch June 21, 2020 10:40
This was referenced Jun 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0