-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of missing psycopg2 module (#104)
Execution of install_all_patches in the environment with no psycopg2/psycopg2-binary leads to raising of an ImportError. These changes also: - add test for missing modules handling
- Loading branch information
1 parent
32f3f88
commit 59bd920
Showing
14 changed files
with
53 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
|
||
try: | ||
import redis | ||
except ImportError: # pragma: no cover | ||
except ImportError: | ||
redis = None | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/opentracing_instrumentation/test_missing_modules_handling.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import os | ||
from importlib import import_module | ||
|
||
import pytest | ||
|
||
from opentracing_instrumentation.client_hooks import install_all_patches | ||
|
||
|
||
HOOKS_WITH_PATCHERS = ('boto3', 'celery', 'mysqldb', 'sqlalchemy', 'requests') | ||
|
||
|
||
@pytest.mark.skipif(os.environ.get('TEST_MISSING_MODULES_HANDLING') != '1', | ||
reason='Not this time') | ||
def test_missing_modules_handling(): | ||
install_all_patches() | ||
for name in HOOKS_WITH_PATCHERS: | ||
hook_module = import_module( | ||
'opentracing_instrumentation.client_hooks.' + name | ||
) | ||
assert not hook_module.patcher.applicable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
[tox] | ||
envlist = py{27,35,36}-celery{3,4},py37-celery4 | ||
envlist = | ||
py{27,35,36}-celery{3,4} | ||
py37-celery4 | ||
py{27,35,36,37}-missing_modules | ||
skip_missing_interpreters = true | ||
|
||
[testenv] | ||
setenv = | ||
missing_modules: TEST_MISSING_MODULES_HANDLING=1 | ||
deps = | ||
celery3: celery~=3.0 | ||
celery4: celery~=4.0 | ||
-rrequirements-test.txt | ||
extras = tests | ||
missing_modules: pytest-cov | ||
extras = | ||
!missing_modules: tests | ||
commands = | ||
flake8 | ||
pytest --cov=opentracing_instrumentation --cov-append -rs | ||
!missing_modules: flake8 | ||
!missing_modules: pytest | ||
missing_modules: pytest tests/opentracing_instrumentation/test_missing_modules_handling.py |