Skip to content

Commit eda0c89

Browse files
ipmbbhautikpipsrprash
authored
Add testing for current Django versions (#200)
* Test multiple Django versions * Remove/change deprecated Django modules * Make all tox envs run on Travis * Scope sqlite3 patch and apply for Django Previously the patch was global which caused the django tests to fail if the sqlite3 tests weren't also run. * Fix tox environments for Django Co-authored-by: Bhautik Pipaliya <[email protected]> Co-authored-by: srprash <[email protected]>
1 parent 672062f commit eda0c89

File tree

4 files changed

+23
-13
lines changed

4 files changed

+23
-13
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ python:
99
- "3.8"
1010

1111
install:
12-
- pip install tox
12+
- pip install tox tox-travis
1313

1414
notifications:
1515
email:
@@ -19,4 +19,4 @@ notifications:
1919
on_failure: always
2020

2121
script:
22-
- tox -e $(echo py$TRAVIS_PYTHON_VERSION | tr -d .)
22+
- tox

tests/ext/django/test_middleware.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from aws_xray_sdk.core import xray_recorder, lambda_launcher
77
from aws_xray_sdk.core.context import Context
88
from aws_xray_sdk.core.models import http, facade_segment, segment
9+
from aws_xray_sdk.core import patch
910
from tests.util import get_new_stubbed_recorder
1011
import os
1112

@@ -66,6 +67,7 @@ def test_fault(self):
6667
assert exception.type == 'KeyError'
6768

6869
def test_db(self):
70+
patch(('sqlite3',))
6971
url = reverse('call_db')
7072
self.client.get(url)
7173
segment = xray_recorder.emitter.pop()

tests/ext/sqlite3/test_sqlite3.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
from aws_xray_sdk.core import xray_recorder
77
from aws_xray_sdk.core.context import Context
88

9-
patch(('sqlite3',))
10-
db = sqlite3.connect(":memory:")
9+
10+
@pytest.fixture(scope="module")
11+
def db():
12+
patch(('sqlite3',))
13+
return sqlite3.connect(":memory:")
1114

1215

1316
@pytest.fixture(autouse=True)
@@ -24,7 +27,8 @@ def construct_ctx():
2427
xray_recorder.clear_trace_entities()
2528

2629

27-
def test_execute():
30+
def test_execute(db):
31+
2832
q = 'SELECT name FROM sqlite_master'
2933
db.execute(q)
3034

@@ -35,7 +39,7 @@ def test_execute():
3539
assert sql['database_version']
3640

3741

38-
def test_invalid_syntax():
42+
def test_invalid_syntax(db):
3943
q = 'some_query'
4044
try:
4145
db.execute(q)

tox.ini

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[tox]
22
envlist =
3-
py{27,34,35,36,37,38}
3+
py{27,34,35,36,37,38}-default
44
py{35,36,37,38}-aiohttp2
5+
py{27,34,35,36,37}-django111
6+
py{35,36,37,38}-django22
7+
py{36,37,38}-django30
58
coverage-report
69

710
skip_missing_interpreters = True
@@ -18,9 +21,10 @@ deps =
1821
sqlalchemy
1922
Flask-SQLAlchemy
2023
future
21-
# the sdk doesn't support earlier version of django
22-
django >= 1.10
23-
django-fake-model
24+
django111: Django==1.11.*
25+
django22: Django==2.2.*
26+
django30: Django==3.0.*
27+
django{111,22,30}: django-fake-model
2428
pynamodb >= 3.3.1
2529
pymysql
2630
psycopg2
@@ -38,9 +42,9 @@ deps =
3842
py{35,36,37,38}: aiobotocore >= 0.10.0
3943

4044
commands =
41-
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
42-
codecov
43-
py{35,36,37,38}: coverage run --source aws_xray_sdk -m py.test tests
45+
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
46+
py{35,36,37,38}-default: coverage run --source aws_xray_sdk -m py.test --ignore tests/ext/django tests
47+
django{111,22,30}: coverage run --source aws_xray_sdk -m py.test tests/ext/django
4448
codecov
4549

4650
setenv =

0 commit comments

Comments
 (0)