diff --git a/.travis.yml b/.travis.yml index ded23805..74c53b66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ python: - "3.8" install: - - pip install tox + - pip install tox tox-travis notifications: email: @@ -19,4 +19,4 @@ notifications: on_failure: always script: - - tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d .) + - tox diff --git a/tests/ext/django/test_middleware.py b/tests/ext/django/test_middleware.py index 8388b386..f7fd24a1 100644 --- a/tests/ext/django/test_middleware.py +++ b/tests/ext/django/test_middleware.py @@ -6,6 +6,7 @@ from aws_xray_sdk.core import xray_recorder, lambda_launcher from aws_xray_sdk.core.context import Context from aws_xray_sdk.core.models import http, facade_segment, segment +from aws_xray_sdk.core import patch from tests.util import get_new_stubbed_recorder import os @@ -66,6 +67,7 @@ def test_fault(self): assert exception.type == 'KeyError' def test_db(self): + patch(('sqlite3',)) url = reverse('call_db') self.client.get(url) segment = xray_recorder.emitter.pop() diff --git a/tests/ext/sqlite3/test_sqlite3.py b/tests/ext/sqlite3/test_sqlite3.py index 86889873..3d0e555b 100644 --- a/tests/ext/sqlite3/test_sqlite3.py +++ b/tests/ext/sqlite3/test_sqlite3.py @@ -6,8 +6,11 @@ from aws_xray_sdk.core import xray_recorder from aws_xray_sdk.core.context import Context -patch(('sqlite3',)) -db = sqlite3.connect(":memory:") + +@pytest.fixture(scope="module") +def db(): + patch(('sqlite3',)) + return sqlite3.connect(":memory:") @pytest.fixture(autouse=True) @@ -24,7 +27,8 @@ def construct_ctx(): xray_recorder.clear_trace_entities() -def test_execute(): +def test_execute(db): + q = 'SELECT name FROM sqlite_master' db.execute(q) @@ -35,7 +39,7 @@ def test_execute(): assert sql['database_version'] -def test_invalid_syntax(): +def test_invalid_syntax(db): q = 'some_query' try: db.execute(q) diff --git a/tox.ini b/tox.ini index 55525561..8e2d496a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,10 @@ [tox] envlist = - py{27,34,35,36,37,38} + py{27,34,35,36,37,38}-default py{35,36,37,38}-aiohttp2 + py{27,34,35,36,37}-django111 + py{35,36,37,38}-django22 + py{36,37,38}-django30 coverage-report skip_missing_interpreters = True @@ -18,9 +21,10 @@ deps = sqlalchemy Flask-SQLAlchemy future - # the sdk doesn't support earlier version of django - django >= 1.10 - django-fake-model + django111: Django==1.11.* + django22: Django==2.2.* + django30: Django==3.0.* + django{111,22,30}: django-fake-model pynamodb >= 3.3.1 pymysql psycopg2 @@ -38,9 +42,9 @@ deps = py{35,36,37,38}: aiobotocore >= 0.10.0 commands = - py{27,34}: coverage run --source aws_xray_sdk -m py.test tests --ignore tests/ext/aiohttp --ignore tests/ext/aiobotocore --ignore tests/test_async_local_storage.py --ignore tests/test_async_recorder.py - codecov - py{35,36,37,38}: coverage run --source aws_xray_sdk -m py.test tests + py{27,34}-default: coverage run --source aws_xray_sdk -m py.test tests --ignore tests/ext/aiohttp --ignore tests/ext/aiobotocore --ignore tests/ext/django --ignore tests/test_async_local_storage.py --ignore tests/test_async_recorder.py + py{35,36,37,38}-default: coverage run --source aws_xray_sdk -m py.test --ignore tests/ext/django tests + django{111,22,30}: coverage run --source aws_xray_sdk -m py.test tests/ext/django codecov setenv =