Skip to content

Update test envs & supported versions #151

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 8 commits into from
Aug 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ jobs:
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
versionSpec: '3.9'
architecture: 'x64'
- script: |
pip install tox
@@ -15,14 +15,12 @@ jobs:
vmImage: 'ubuntu-16.04'
strategy:
matrix:
Python27:
python.version: '2.7'
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
Python38:
python.version: '3.8'
Python39:
python.version: '3.9'
maxParallel: 4

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

- script: |
pip install wheel
pip install tox tox-docker
tox
displayName: 'tox'
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -64,8 +64,8 @@ not be accepted, and future changes may break compatibility in older
versions.

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

20 changes: 4 additions & 16 deletions flask_pymongo/__init__.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@

from functools import partial
from mimetypes import guess_type
import sys

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


PY2 = sys.version_info[0] == 2

# Python 3 compatibility
if PY2:
text_type = (str, unicode)
num_type = (int, long)
else:
text_type = str
num_type = int


DESCENDING = pymongo.DESCENDING
"""Descending sort order."""

@@ -151,11 +139,11 @@ def get_upload(filename):
:param int cache_for: number of seconds that browsers should be
instructed to cache responses
"""
if not isinstance(base, text_type):
if not isinstance(base, str):
raise TypeError("'base' must be string or unicode")
if not isinstance(version, num_type):
if not isinstance(version, int):
raise TypeError("'version' must be an integer")
if not isinstance(cache_for, num_type):
if not isinstance(cache_for, int):
raise TypeError("'cache_for' must be an integer")

storage = GridFS(self.db, base)
@@ -200,7 +188,7 @@ def save_upload(filename):
:param kwargs: extra attributes to be stored in the file's document,
passed directly to :meth:`gridfs.GridFS.put`
"""
if not isinstance(base, text_type):
if not isinstance(base, str):
raise TypeError("'base' must be string or unicode")
if not (hasattr(fileobj, "read") and callable(fileobj.read)):
raise TypeError("'fileobj' must have read() method")
17 changes: 16 additions & 1 deletion flask_pymongo/tests/util.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,22 @@ class ToxDockerMixin(object):
def setUp(self):
super(ToxDockerMixin, self).setUp()

self.port = int(os.environ.get("MONGO_27017_TCP", 27017))
# tox-docker could be running any version; find the env
# var that looks like what tox-docker would provide, but
# fail if there are more than one
env_vars = [
(k, v)
for k, v in os.environ.items()
if k.startswith("MONGO") and k.endswith("_TCP_PORT")
]

self.port = 27017
if len(env_vars) == 1:
self.port = int(env_vars[0][1])
else:
self.fail(
f"too many tox-docker mongo port env vars (found {len(env_vars)})",
)


class FlaskRequestTest(ToxDockerMixin, unittest.TestCase):
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -40,10 +40,9 @@
"Intended Audience :: Developers",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Topic :: Internet :: WWW/HTTP :: Dynamic Content",
"Topic :: Software Development :: Libraries :: Python Modules"
32 changes: 21 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -2,35 +2,33 @@

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

[testenv]
docker =
mongo34: mongo:3.4
mongo36: mongo:3.6
mongo40: mongo:4.0
mongo42: mongo:4.2
mongo40: mongo40
mongo42: mongo42
mongo44: mongo44
mongo50: mongo50

deps =
pytest

pymongo33: pymongo>=3.3,<3.4
pymongo34: pymongo>=3.4,<3.5
pymongo35: pymongo>=3.5,<3.6
pymongo36: pymongo>=3.6,<3.7
pymongo37: pymongo>=3.7,<3.8
pymongo38: pymongo>=3.8,<3.9
pymongo39: pymongo>=3.9,<3.10
pymongo310: pymongo>=3.10,<3.11
pymongo311: pymongo>=3.11,<3.12
pymongo312: pymongo>=3.12,<3.13

flask0_12: flask>=0.12,<1.0
flask10: flask>=1.0,<1.1
flask11: flask>=1.1,<1.2
flask20: flask>=2.0,<2.1

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

[testenv:style]
basepython = python2.7
skipsdist = true
skip_install = true
deps =
@@ -51,3 +49,15 @@ import-order-style = fromsfirst
ignore = D100,D104,D107
exclude =
_version.py

[docker:mongo40]
image = mongo:4.0

[docker:mongo42]
image = mongo:4.2

[docker:mongo44]
image = mongo:4.4

[docker:mongo50]
image = mongo:5.0