Skip to content

Commit ce80ec8

Browse files
authored
Update test envs & supported versions (#151)
* Drop PyMongo 3.3 - 3.6; drop MongoDB 3.4; drop Py2.7 and Py3.6 * Add PyMongo 3.10 - 3.12; add MongoDB 4.4 and 5.0; add Py3.9 * Remove Python 2.x compatibility code * Update to tox-docker 3 and update tox configuration
1 parent 3029f58 commit ce80ec8

File tree

6 files changed

+51
-40
lines changed

6 files changed

+51
-40
lines changed

azure-pipelines.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ jobs:
33
steps:
44
- task: UsePythonVersion@0
55
inputs:
6-
versionSpec: '3.7'
6+
versionSpec: '3.9'
77
architecture: 'x64'
88
- script: |
99
pip install tox
@@ -15,14 +15,12 @@ jobs:
1515
vmImage: 'ubuntu-16.04'
1616
strategy:
1717
matrix:
18-
Python27:
19-
python.version: '2.7'
20-
Python35:
21-
python.version: '3.5'
22-
Python36:
23-
python.version: '3.6'
2418
Python37:
2519
python.version: '3.7'
20+
Python38:
21+
python.version: '3.8'
22+
Python39:
23+
python.version: '3.9'
2624
maxParallel: 4
2725

2826
steps:
@@ -32,6 +30,7 @@ jobs:
3230
architecture: 'x64'
3331

3432
- script: |
33+
pip install wheel
3534
pip install tox tox-docker
3635
tox
3736
displayName: 'tox'

docs/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ not be accepted, and future changes may break compatibility in older
6464
versions.
6565

6666
Flask-PyMongo is tested against `supported versions
67-
<https://www.mongodb.com/support-policy>`_ of MongoDB, and Python 2.7
68-
and 3.5+. For the exact list of version combinations that are tested and
67+
<https://www.mongodb.com/support-policy>`_ of MongoDB, and Python
68+
and 3.6+. For the exact list of version combinations that are tested and
6969
known to be compatible, see the `envlist` in `tox.ini
7070
<https://github.com/dcrosta/flask-pymongo/blob/master/tox.ini>`_.
7171

flask_pymongo/__init__.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
from functools import partial
3030
from mimetypes import guess_type
31-
import sys
3231

3332
from flask import abort, current_app, request
3433
from gridfs import GridFS, NoFile
@@ -40,17 +39,6 @@
4039
from flask_pymongo.wrappers import MongoClient
4140

4241

43-
PY2 = sys.version_info[0] == 2
44-
45-
# Python 3 compatibility
46-
if PY2:
47-
text_type = (str, unicode)
48-
num_type = (int, long)
49-
else:
50-
text_type = str
51-
num_type = int
52-
53-
5442
DESCENDING = pymongo.DESCENDING
5543
"""Descending sort order."""
5644

@@ -151,11 +139,11 @@ def get_upload(filename):
151139
:param int cache_for: number of seconds that browsers should be
152140
instructed to cache responses
153141
"""
154-
if not isinstance(base, text_type):
142+
if not isinstance(base, str):
155143
raise TypeError("'base' must be string or unicode")
156-
if not isinstance(version, num_type):
144+
if not isinstance(version, int):
157145
raise TypeError("'version' must be an integer")
158-
if not isinstance(cache_for, num_type):
146+
if not isinstance(cache_for, int):
159147
raise TypeError("'cache_for' must be an integer")
160148

161149
storage = GridFS(self.db, base)
@@ -200,7 +188,7 @@ def save_upload(filename):
200188
:param kwargs: extra attributes to be stored in the file's document,
201189
passed directly to :meth:`gridfs.GridFS.put`
202190
"""
203-
if not isinstance(base, text_type):
191+
if not isinstance(base, str):
204192
raise TypeError("'base' must be string or unicode")
205193
if not (hasattr(fileobj, "read") and callable(fileobj.read)):
206194
raise TypeError("'fileobj' must have read() method")

flask_pymongo/tests/util.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,22 @@ class ToxDockerMixin(object):
1515
def setUp(self):
1616
super(ToxDockerMixin, self).setUp()
1717

18-
self.port = int(os.environ.get("MONGO_27017_TCP", 27017))
18+
# tox-docker could be running any version; find the env
19+
# var that looks like what tox-docker would provide, but
20+
# fail if there are more than one
21+
env_vars = [
22+
(k, v)
23+
for k, v in os.environ.items()
24+
if k.startswith("MONGO") and k.endswith("_TCP_PORT")
25+
]
26+
27+
self.port = 27017
28+
if len(env_vars) == 1:
29+
self.port = int(env_vars[0][1])
30+
else:
31+
self.fail(
32+
f"too many tox-docker mongo port env vars (found {len(env_vars)})",
33+
)
1934

2035

2136
class FlaskRequestTest(ToxDockerMixin, unittest.TestCase):

setup.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@
4040
"Intended Audience :: Developers",
4141
"License :: OSI Approved :: BSD License",
4242
"Operating System :: OS Independent",
43-
"Programming Language :: Python :: 2.7",
44-
"Programming Language :: Python :: 3.5",
45-
"Programming Language :: Python :: 3.6",
4643
"Programming Language :: Python :: 3.7",
44+
"Programming Language :: Python :: 3.8",
45+
"Programming Language :: Python :: 3.9",
4746
"Programming Language :: Python",
4847
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
4948
"Topic :: Software Development :: Libraries :: Python Modules"

tox.ini

+21-11
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,33 @@
22

33
; keep the pymongo list in sync with what's in .travis.yaml
44
envlist=
5-
pymongo{33,34,35,36,37,38,39}-mongo{34,36,40,42}-flask{0_12,10,11}, style
5+
pymongo{37,38,39,310,311,312}-mongo{40,42,44,50}-flask{10,11,20}, style
66

77
[testenv]
88
docker =
9-
mongo34: mongo:3.4
10-
mongo36: mongo:3.6
11-
mongo40: mongo:4.0
12-
mongo42: mongo:4.2
9+
mongo40: mongo40
10+
mongo42: mongo42
11+
mongo44: mongo44
12+
mongo50: mongo50
1313

1414
deps =
1515
pytest
1616

17-
pymongo33: pymongo>=3.3,<3.4
18-
pymongo34: pymongo>=3.4,<3.5
19-
pymongo35: pymongo>=3.5,<3.6
20-
pymongo36: pymongo>=3.6,<3.7
2117
pymongo37: pymongo>=3.7,<3.8
2218
pymongo38: pymongo>=3.8,<3.9
2319
pymongo39: pymongo>=3.9,<3.10
20+
pymongo310: pymongo>=3.10,<3.11
21+
pymongo311: pymongo>=3.11,<3.12
22+
pymongo312: pymongo>=3.12,<3.13
2423

25-
flask0_12: flask>=0.12,<1.0
2624
flask10: flask>=1.0,<1.1
2725
flask11: flask>=1.1,<1.2
26+
flask20: flask>=2.0,<2.1
2827

2928
commands =
3029
{envbindir}/py.test --tb=native {toxinidir}
3130

3231
[testenv:style]
33-
basepython = python2.7
3432
skipsdist = true
3533
skip_install = true
3634
deps =
@@ -51,3 +49,15 @@ import-order-style = fromsfirst
5149
ignore = D100,D104,D107
5250
exclude =
5351
_version.py
52+
53+
[docker:mongo40]
54+
image = mongo:4.0
55+
56+
[docker:mongo42]
57+
image = mongo:4.2
58+
59+
[docker:mongo44]
60+
image = mongo:4.4
61+
62+
[docker:mongo50]
63+
image = mongo:5.0

0 commit comments

Comments
 (0)