From f616db674029942759616ab165b7a8fc247090c2 Mon Sep 17 00:00:00 2001 From: Awais Qureshi Date: Mon, 11 Nov 2019 16:38:26 +0500 Subject: [PATCH] BOM-1025 Adding tox for django20,21,22 --- .travis.yml | 20 +++++++++++++++----- pylintrc | 2 +- requirements/base.in | 2 +- requirements/base.txt | 9 ++++----- requirements/constraints.txt | 18 ++++++++++++++++++ requirements/dev.in | 1 + requirements/dev.txt | 34 +++++++++++++++++----------------- requirements/django.in | 4 +++- requirements/django.txt | 18 +++++++++--------- requirements/doc.in | 2 ++ requirements/doc.txt | 18 +++++++++--------- requirements/pip-tools.in | 2 ++ requirements/pip-tools.txt | 2 +- requirements/test.in | 2 ++ requirements/test.txt | 34 +++++++++++++++++----------------- requirements/travis.in | 2 ++ requirements/travis.txt | 8 ++++---- setup.py | 5 ++++- tox.ini | 14 ++++++-------- xblock/VERSION.txt | 2 +- xblock/core.py | 1 + xblock/field_data.py | 1 + xblock/fields.py | 9 +++++---- xblock/runtime.py | 2 ++ 24 files changed, 128 insertions(+), 84 deletions(-) create mode 100644 requirements/constraints.txt diff --git a/.travis.yml b/.travis.yml index c96f5754b..3b959345e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,17 +2,27 @@ language: python sudo: false python: - 2.7 - - 3.6 + - 3.5 cache: pip install: - pip install -r requirements/travis.txt env: - TOX_ENV=django111 + - TOX_ENV=django20 + - TOX_ENV=django21 + - TOX_ENV=django22 matrix: + exclude: + - python: 2.7 + env: TOX_ENV=django20 + - python: 2.7 + env: TOX_ENV=django21 + - python: 2.7 + env: TOX_ENV=django22 include: - - python: 3.6 + - python: 3.5 env: TOX_ENV=docs - - python: 3.6 + - python: 3.5 env: TOX_ENV=quality script: - tox -e $TOX_ENV @@ -26,5 +36,5 @@ deploy: distributions: sdist bdist_wheel on: tags: true - python: 3.6 - condition: '$TOX_ENV = django111' + python: 3.5 + condition: '$TOX_ENV = quality' diff --git a/pylintrc b/pylintrc index 8fc862696..aa471e9b5 100644 --- a/pylintrc +++ b/pylintrc @@ -136,7 +136,7 @@ class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$ inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$ # Good variable names which should always be accepted, separated by a comma -good-names=i,j,k,ex,Run,_ +good-names=i,j,k,ex,Run,_,e # Bad variable names which should always be refused, separated by a comma bad-names=foo,bar,baz,toto,tutu,tata diff --git a/requirements/base.in b/requirements/base.in index 649886ace..5a4745644 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,7 +1,7 @@ # Core requirements for using this package +-c constraints.txt fs -futures ; python_version == "2.7" # via s3transfer lxml markupsafe python-dateutil diff --git a/requirements/base.txt b/requirements/base.txt index a0130c894..2f5085695 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -8,18 +8,17 @@ appdirs==1.4.3 # via fs backports.os==0.1.1 # via fs enum34==1.1.6 # via fs fs==2.4.11 -future==0.18.1 # via backports.os -futures==3.3.0 ; python_version == "2.7" +future==0.18.2 # via backports.os lxml==4.4.1 markupsafe==1.1.1 python-dateutil==2.8.0 pytz==2019.3 pyyaml==5.1.2 simplejson==3.16.0 -six==1.12.0 +six==1.13.0 typing==3.7.4.1 # via fs -web-fragments==0.3.0 +web-fragments==0.3.1 webob==1.8.5 # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via fs +# setuptools==41.6.0 # via fs diff --git a/requirements/constraints.txt b/requirements/constraints.txt new file mode 100644 index 000000000..790851b72 --- /dev/null +++ b/requirements/constraints.txt @@ -0,0 +1,18 @@ +# Version constraints for pip installation. +# +# This file doesn't install any packages. It specifies version constraints +# that will be applied if a package is needed. +# +# When pinning something here, please provide an explanation of why. Ideally, +# link to other information that will help people in the future to remove the +# pin when possible. Writing an issue against the offending project and +# linking to it here is good. + + +# futures is part of the builtin python in python3 +futures ; python_version == "2.7" + + +# latest botocore release cap upper version of python-dateutil to 2.8.0 and that is not +# compatible with other packages. That's why adding a cap here to avoid boto latest release untill they fix the issue. +botocore<1.14.0,>=1.13.17 diff --git a/requirements/dev.in b/requirements/dev.in index a42c80295..5d0b745d0 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,5 +1,6 @@ # Dependencies that are used in development environments. # Please do not use this file for packages that are needed for package installation or for test runs. +-c constraints.txt -r pip-tools.txt # pip-tools and its dependencies, for managing requirements files -r test.txt # Dependencies for running the various test suites diff --git a/requirements/dev.txt b/requirements/dev.txt index 6cb5e2588..6f4d009b0 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -9,11 +9,11 @@ argparse==1.4.0 astroid==1.6.6 atomicwrites==1.3.0 attrs==19.3.0 -backports.functools-lru-cache==1.5 +backports.functools-lru-cache==1.6.1 backports.os==0.1.1 -boto3==1.10.0 -botocore==1.13.0 -caniusepython3==7.1.0 +boto3==1.10.17 +botocore==1.13.17 +caniusepython3==7.2.0 certifi==2019.9.11 chardet==3.0.4 click==7.0 @@ -23,26 +23,26 @@ contextlib2==0.6.0.post1 coverage==4.5.4 ddt==1.2.1 diff-cover==2.4.0 -distlib==0.2.9.post0 +distlib==0.3.0 django-pyfs==2.0 -django==1.11.25 +django==1.11.26 docutils==0.15.2 enum34==1.1.6 filelock==3.0.12 fs-s3fs==1.1.1 fs==2.4.11 funcsigs==1.0.2 -future==0.18.1 +future==0.18.2 futures==3.3.0 ; python_version == "2.7" -hypothesis==4.41.3 +hypothesis==4.44.2 idna==2.8 importlib-metadata==0.23 -inflect==2.1.0 +inflect==3.0.2 isort==4.3.21 jinja2-pluralize==0.3.0 jinja2==2.10.3 jmespath==0.9.4 -lazy-object-proxy==1.4.2 +lazy-object-proxy==1.4.3 lazy==1.4 lxml==4.4.1 markupsafe==1.1.1 @@ -59,9 +59,9 @@ py==1.8.0 pycodestyle==2.5.0 pygments==2.4.2 pylint==1.9.5 -pyparsing==2.4.2 +pyparsing==2.4.5 pytest-cov==2.8.1 -pytest-django==3.6.0 +pytest-django==3.7.0 pytest==4.6.6 python-dateutil==2.8.0 pytz==2019.3 @@ -71,18 +71,18 @@ s3transfer==0.2.1 scandir==1.10.0 simplejson==3.16.0 singledispatch==3.4.0.3 -six==1.12.0 +six==1.13.0 toml==0.10.0 tox-battery==0.5.1 -tox==3.14.0 +tox==3.14.1 typing==3.7.4.1 -urllib3==1.25.6 +urllib3==1.25.7 virtualenv==16.7.7 wcwidth==0.1.7 -web-fragments==0.3.0 +web-fragments==0.3.1 webob==1.8.5 wrapt==1.11.2 zipp==0.6.0 # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via caniusepython3, fs +# setuptools==41.6.0 # via caniusepython3, fs diff --git a/requirements/django.in b/requirements/django.in index 14a1cb491..c0d0b0420 100644 --- a/requirements/django.in +++ b/requirements/django.in @@ -1,8 +1,10 @@ # Install Django requirements, if we're using the optional Django-integrated # parts of XBlock +-c constraints.txt + -r base.txt # Core XBlock dependencies -Django>=1.8,<2.0 +Django>=1.11 django-pyfs>=1.0.5 lazy diff --git a/requirements/django.txt b/requirements/django.txt index 8fe1aaf04..2b2876811 100644 --- a/requirements/django.txt +++ b/requirements/django.txt @@ -6,16 +6,16 @@ # appdirs==1.4.3 backports.os==0.1.1 -boto3==1.10.0 # via fs-s3fs -botocore==1.13.0 # via boto3, s3transfer +boto3==1.10.17 # via fs-s3fs +botocore==1.13.17 # via boto3, s3transfer django-pyfs==2.0 -django==1.11.25 +django==1.11.26 docutils==0.15.2 # via botocore enum34==1.1.6 fs-s3fs==1.1.1 # via django-pyfs fs==2.4.11 -future==0.18.1 -futures==3.3.0 ; python_version == "2.7" +future==0.18.2 +futures==3.3.0 ; python_version == "2.7" # via s3transfer jmespath==0.9.4 # via boto3, botocore lazy==1.4 lxml==4.4.1 @@ -25,11 +25,11 @@ pytz==2019.3 pyyaml==5.1.2 s3transfer==0.2.1 # via boto3 simplejson==3.16.0 -six==1.12.0 +six==1.13.0 typing==3.7.4.1 -urllib3==1.25.6 # via botocore -web-fragments==0.3.0 +urllib3==1.25.7 # via botocore +web-fragments==0.3.1 webob==1.8.5 # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via fs +# setuptools==41.6.0 # via fs diff --git a/requirements/doc.in b/requirements/doc.in index 86937c3c0..25b502406 100644 --- a/requirements/doc.in +++ b/requirements/doc.in @@ -1,6 +1,8 @@ # Packages we need in order to build the docs, separated out so that rtfd.org # can install them. +-c constraints.txt + -r django.txt # Package dependencies, including optional Django support edx-sphinx-theme diff --git a/requirements/doc.txt b/requirements/doc.txt index 85dd41647..d04d5916a 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -8,19 +8,19 @@ alabaster==0.7.12 # via sphinx appdirs==1.4.3 babel==2.7.0 # via sphinx backports.os==0.1.1 -boto3==1.10.0 -botocore==1.13.0 +boto3==1.10.17 +botocore==1.13.17 certifi==2019.9.11 # via requests chardet==3.0.4 # via requests django-pyfs==2.0 -django==1.11.25 +django==1.11.26 docutils==0.15.2 edx-sphinx-theme==1.5.0 enum34==1.1.6 fs-s3fs==1.1.1 fs==2.4.11 funcsigs==1.0.2 # via mock -future==0.18.1 +future==0.18.2 futures==3.3.0 ; python_version == "2.7" idna==2.8 # via requests imagesize==1.1.0 # via sphinx @@ -32,21 +32,21 @@ markupsafe==1.1.1 mock==3.0.5 packaging==19.2 # via sphinx pygments==2.4.2 # via sphinx -pyparsing==2.4.2 # via packaging +pyparsing==2.4.5 # via packaging python-dateutil==2.8.0 pytz==2019.3 pyyaml==5.1.2 requests==2.22.0 # via sphinx s3transfer==0.2.1 simplejson==3.16.0 -six==1.12.0 +six==1.13.0 snowballstemmer==2.0.0 # via sphinx sphinx==1.8.5 sphinxcontrib-websupport==1.1.2 # via sphinx typing==3.7.4.1 -urllib3==1.25.6 -web-fragments==0.3.0 +urllib3==1.25.7 +web-fragments==0.3.1 webob==1.8.5 # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via fs, sphinx +# setuptools==41.6.0 # via fs, sphinx diff --git a/requirements/pip-tools.in b/requirements/pip-tools.in index bc3606eff..c0d088974 100644 --- a/requirements/pip-tools.in +++ b/requirements/pip-tools.in @@ -1,3 +1,5 @@ # Just the dependencies to run pip-tools, mainly for the "upgrade" make target +-c constraints.txt + pip-tools # Contains pip-compile, used to generate pip requirements files diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index d9cd2ef87..050562c32 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.txt @@ -6,4 +6,4 @@ # click==7.0 # via pip-tools pip-tools==4.2.0 -six==1.12.0 # via pip-tools +six==1.13.0 # via pip-tools diff --git a/requirements/test.in b/requirements/test.in index 0f84142cf..b25ac852d 100644 --- a/requirements/test.in +++ b/requirements/test.in @@ -1,5 +1,7 @@ # Requirements for test runs +-c constraints.txt + -r django.txt # Package dependencies, including optional Django support astroid diff --git a/requirements/test.txt b/requirements/test.txt index 4593b33c7..bdde4a790 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -9,11 +9,11 @@ argparse==1.4.0 # via caniusepython3 astroid==1.6.6 atomicwrites==1.3.0 # via pytest attrs==19.3.0 # via hypothesis, pytest -backports.functools-lru-cache==1.5 # via astroid, caniusepython3, isort, pylint +backports.functools-lru-cache==1.6.1 # via astroid, caniusepython3, isort, pylint backports.os==0.1.1 -boto3==1.10.0 -botocore==1.13.0 -caniusepython3==7.1.0 +boto3==1.10.17 +botocore==1.13.17 +caniusepython3==7.2.0 certifi==2019.9.11 # via requests chardet==3.0.4 # via requests configparser==4.0.2 # via importlib-metadata, pylint @@ -21,7 +21,7 @@ contextlib2==0.6.0.post1 # via importlib-metadata coverage==4.5.4 ddt==1.2.1 diff-cover==2.4.0 -distlib==0.2.9.post0 # via caniusepython3 +distlib==0.3.0 # via caniusepython3 django-pyfs==2.0 docutils==0.15.2 enum34==1.1.6 @@ -29,17 +29,17 @@ filelock==3.0.12 # via tox fs-s3fs==1.1.1 fs==2.4.11 funcsigs==1.0.2 # via mock, pytest -future==0.18.1 +future==0.18.2 futures==3.3.0 ; python_version == "2.7" -hypothesis==4.41.3 +hypothesis==4.44.2 idna==2.8 # via requests -importlib-metadata==0.23 # via path.py, pluggy, pytest, tox -inflect==2.1.0 # via jinja2-pluralize +importlib-metadata==0.23 # via inflect, path.py, pluggy, pytest, tox +inflect==3.0.2 # via jinja2-pluralize isort==4.3.21 # via pylint jinja2-pluralize==0.3.0 # via diff-cover jinja2==2.10.3 # via diff-cover, jinja2-pluralize jmespath==0.9.4 -lazy-object-proxy==1.4.2 # via astroid +lazy-object-proxy==1.4.3 # via astroid lazy==1.4 lxml==4.4.1 markupsafe==1.1.1 @@ -55,9 +55,9 @@ py==1.8.0 # via pytest, tox pycodestyle==2.5.0 pygments==2.4.2 # via diff-cover pylint==1.9.5 -pyparsing==2.4.2 # via packaging +pyparsing==2.4.5 # via packaging pytest-cov==2.8.1 -pytest-django==3.6.0 +pytest-django==3.7.0 pytest==4.6.6 python-dateutil==2.8.0 pytz==2019.3 @@ -67,17 +67,17 @@ s3transfer==0.2.1 scandir==1.10.0 # via pathlib2 simplejson==3.16.0 singledispatch==3.4.0.3 # via astroid, pylint -six==1.12.0 +six==1.13.0 toml==0.10.0 # via tox -tox==3.14.0 +tox==3.14.1 typing==3.7.4.1 -urllib3==1.25.6 +urllib3==1.25.7 virtualenv==16.7.7 # via tox wcwidth==0.1.7 # via pytest -web-fragments==0.3.0 +web-fragments==0.3.1 webob==1.8.5 wrapt==1.11.2 # via astroid zipp==0.6.0 # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: -# setuptools==41.4.0 # via caniusepython3, fs +# setuptools==41.6.0 # via caniusepython3, fs diff --git a/requirements/travis.in b/requirements/travis.in index 3d651d6c1..769efaca6 100644 --- a/requirements/travis.in +++ b/requirements/travis.in @@ -1,5 +1,7 @@ # Requirements for running tests in Travis +-c constraints.txt + codecov # Code coverage reporting tox # Virtualenv management for tests tox-battery # Makes tox aware of requirements file changes diff --git a/requirements/travis.txt b/requirements/travis.txt index acef7a6d1..5258fefc4 100644 --- a/requirements/travis.txt +++ b/requirements/travis.txt @@ -18,13 +18,13 @@ packaging==19.2 # via tox pathlib2==2.3.5 # via importlib-metadata pluggy==0.13.0 # via tox py==1.8.0 # via tox -pyparsing==2.4.2 # via packaging +pyparsing==2.4.5 # via packaging requests==2.22.0 # via codecov scandir==1.10.0 # via pathlib2 -six==1.12.0 # via more-itertools, packaging, pathlib2, tox +six==1.13.0 # via more-itertools, packaging, pathlib2, tox toml==0.10.0 # via tox tox-battery==0.5.1 -tox==3.14.0 -urllib3==1.25.6 # via requests +tox==3.14.1 +urllib3==1.25.7 # via requests virtualenv==16.7.7 # via tox zipp==0.6.0 # via importlib-metadata diff --git a/setup.py b/setup.py index 10a287876..ea05ca1de 100755 --- a/setup.py +++ b/setup.py @@ -48,12 +48,15 @@ 'Development Status :: 5 - Production/Stable', 'Framework :: Django', 'Framework :: Django :: 1.11', + 'Framework :: Django :: 2.0', + 'Framework :: Django :: 2.1', + 'Framework :: Django :: 2.2', 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.5", ] ) diff --git a/tox.ini b/tox.ini index 962295709..1304d3b2e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,5 @@ -# Tox (http://tox.testrun.org/) is a tool for running tests -# in multiple virtualenvs. This configuration file will run the -# test suite on all supported python versions. To use it, "pip install tox" -# and then run "tox" from this directory. - [tox] -envlist = py{27,35,36}-django111 +envlist = py{27,35}-django111,py{35}-django{20,21,22} [pytest] DJANGO_SETTINGS_MODULE = xblock.test.settings @@ -16,10 +11,13 @@ norecursedirs = .* doc requirements passenv = CI TRAVIS TRAVIS_* deps = django111: Django>=1.11,<2.0 + django20: Django>=2.0,<2.1 + django21: Django>=2.1,<2.2 + django22: Django>=2.2,<2.3 -r requirements/test.txt changedir = {envsitepackagesdir} commands = - pytest {posargs:xblock} + python -Wd -m pytest {posargs:xblock} mv .coverage {toxinidir}/.coverage whitelist_externals = make @@ -37,7 +35,7 @@ commands = [testenv:quality] deps = - Django>=1.11,<2.0 + django111: Django>=1.11,<2.0 -r requirements/test.txt changedir = {toxinidir} commands = diff --git a/xblock/VERSION.txt b/xblock/VERSION.txt index db6fb4a91..9d4f8239d 100644 --- a/xblock/VERSION.txt +++ b/xblock/VERSION.txt @@ -1 +1 @@ -1.2.8 +1.2.9 diff --git a/xblock/core.py b/xblock/core.py index 31b853b05..fbb97b8d0 100644 --- a/xblock/core.py +++ b/xblock/core.py @@ -173,6 +173,7 @@ def load_tagged_classes(cls, tag, fail_silently=True): if tag in class_._class_tags: yield name, class_ + # pylint: disable=keyword-arg-before-vararg def __init__(self, runtime, field_data=None, scope_ids=UNSET, *args, **kwargs): """ Construct a new XBlock. diff --git a/xblock/field_data.py b/xblock/field_data.py index b28ad0160..e1c46196c 100644 --- a/xblock/field_data.py +++ b/xblock/field_data.py @@ -179,6 +179,7 @@ def default(self, block, name): return self._field_data(block, name).default(block, name) def save_block(self, block): + """ saving data """ field_datas = set(six.itervalues(self._scope_mappings)) for field_data in field_datas: field_data.save_block(block) diff --git a/xblock/fields.py b/xblock/fields.py index 9178d1122..9ac115cef 100644 --- a/xblock/fields.py +++ b/xblock/fields.py @@ -15,9 +15,7 @@ import itertools import json import re -import sys import traceback -import unicodedata import warnings import dateutil.parser @@ -879,7 +877,8 @@ def _sanitize(self, value): if re.search(self.BAD_REGEX, value): new_value = re.sub(self.BAD_REGEX, u"", value) # The new string will be equivalent to the original string if no control characters are present. - # If equivalent, return the original string - some tests check for object equality instead of string equality. + # If equivalent, return the original string - some tests + # check for object equality instead of string equality. return value if value == new_value else new_value else: return value @@ -978,7 +977,9 @@ def from_json(self, value): if not isinstance(value, (datetime.datetime, datetime.timedelta)): raise TypeError( - "Value should be loaded from a string, a datetime object, a timedelta object, or None, not {}".format(type(value)) + "Value should be loaded from a string, a datetime object, a timedelta object, or None, not {}".format( + type(value) + ) ) if isinstance(value, datetime.datetime): diff --git a/xblock/runtime.py b/xblock/runtime.py index ebecb6490..f93cd3249 100644 --- a/xblock/runtime.py +++ b/xblock/runtime.py @@ -612,6 +612,7 @@ def load_aside_type(self, aside_type): """ return XBlockAside.load_class(aside_type, select=self.select) + # pylint: disable = pylint: disable=keyword-arg-before-vararg def construct_xblock(self, block_type, scope_ids, field_data=None, *args, **kwargs): r""" Construct a new xblock of the type identified by block_type, @@ -624,6 +625,7 @@ def construct_xblock(self, block_type, scope_ids, field_data=None, *args, **kwar *args, **kwargs ) + # pylint: disable=keyword-arg-before-vararg def construct_xblock_from_class(self, cls, scope_ids, field_data=None, *args, **kwargs): """ Construct a new xblock of type cls, mixing in the mixins