Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #64 from eduNEXT/lmm/py38
Browse files Browse the repository at this point in the history
[BD-6] Python 3.8 in travis tests
  • Loading branch information
awais786 authored May 8, 2020
2 parents 3d2efbe + 04172c6 commit fdb5aab
Show file tree
Hide file tree
Showing 20 changed files with 150 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .pep8 → .pycodestyle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[pep8]
[pycodestyle]
ignore=E501
max_line_length=119
exclude=settings
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
language: python
python:
- 3.5
- 3.8
env:
- TOXENV=quality
matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.6
env: TOXENV=py36
include:
- python: 3.5
env: TOXENV=py35
- python: 3.8
env: TOXENV=py38
cache: pip
sudo: false
branches:
Expand All @@ -13,7 +18,7 @@ branches:
- /^\d+\.\d+(\.\d+)?(-\S*)?$/
install:
- pip install coveralls
- pip install -r requirements.txt
- pip install -r requirements/tox.txt
script: tox
after_success:
- coveralls
Expand All @@ -24,6 +29,6 @@ deploy:
distributions: sdist bdist_wheel
on:
tags: true
python: 2.7
python: 3.5
password:
secure: niAkz7MPmeGxu+dgicFGm8SydYPy0PYZI8jn/Rcs+B9ASPt8oJ0sFxGLtYLl7b0Rg9UcRrHHfoLOMWYK/0n+cdgGPJEmtXHnxBgzSdliYl5kO16A3omK4s7a8794qJ+4DM/LraFc2jU3Fg1t2PJZp4BuNMVIpSch3iZ3bvWhh/s=
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
include LICENSE
include README.rst
include requirements/base.in
inclue requirements/test.in
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,22 @@ test.requirements:
pip install -q -r requirements/test.txt

test:
nosetests --with-coverage --cover-inclusive --cover-branches \
--cover-html --cover-html-dir=$(COVERAGE)/html/ \
--cover-xml --cover-xml-file=$(COVERAGE)/coverage.xml \
--cover-package=$(PACKAGE) $(PACKAGE)/
pytest $(PACKAGE) --cov-branch \
--cov-report=html:$(COVERAGE)/html/ \
--cov-report=xml:$(COVERAGE)/coverage.xml \
--cov=$(PACKAGE)

quality:
pep8 --config=.pep8 $(PACKAGE)
pycodestyle --config=.pycodestyle $(PACKAGE)
pylint --rcfile=.pylintrc $(PACKAGE)

# Ignore module level docstrings and all test files
pep257 --ignore=D100,D104,D203 --match='(?!test).*py' $(PACKAGE)
# TODO: Quality changes to not ignore D203,D212,D401,D406,D407,D412,D413,D417
pydocstyle --ignore=D100,D104,D203,D212,D401,D406,D407,D412,D413,D417 --match='(?!test).*py' $(PACKAGE)

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
pip install -q pip-tools
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/tox.txt requirements/tox.in
pip-compile --upgrade -o requirements/test.txt requirements/test.in
2 changes: 1 addition & 1 deletion analyticsclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.15.5'
__version__ = '0.16.0'
2 changes: 1 addition & 1 deletion analyticsclient/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from analyticsclient.constants import data_formats, http_methods


class BaseEndpoint(object):
class BaseEndpoint:
"""Base class for endpoints that use a client object."""

def __init__(self, client):
Expand Down
2 changes: 1 addition & 1 deletion analyticsclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
log = logging.getLogger(__name__)


class Client(object):
class Client:
"""
Analytics API client.
Expand Down
8 changes: 0 additions & 8 deletions analyticsclient/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
class ClientError(Exception):
"""Common base class for all client errors."""

pass


class NotFoundError(ClientError):
"""URL was not found."""

pass


class InvalidRequestError(ClientError):
"""The API request was invalid."""

pass


class TimeoutError(ClientError): # pylint: disable=redefined-builtin
"""The API server did not respond before the timeout expired."""

pass
2 changes: 1 addition & 1 deletion analyticsclient/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_api_url(self, path):


@ddt.ddt
class APIWithIDsTestCase(object):
class APIWithIDsTestCase:
"""Base class for tests for API endpoints that take lists of IDs."""

# Override in the subclass:
Expand Down
2 changes: 1 addition & 1 deletion analyticsclient/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def test_strip_trailing_slash(self):
self.assertEqual(client.base_url, url)

# pylint: disable=protected-access
@mock.patch('requests.get', side_effect=requests.exceptions.Timeout)
@log_capture()
@mock.patch('requests.get', side_effect=requests.exceptions.Timeout)
def test_request_timeout(self, mock_get, lc):
url = self.test_url
timeout = None
Expand Down
14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

4 changes: 3 additions & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
requests==2.22.0
-c constraints.txt

requests
8 changes: 4 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# make upgrade
#
certifi==2019.11.28 # via requests
certifi==2020.4.5.1 # via requests
chardet==3.0.4 # via requests
idna==2.8 # via requests
requests==2.22.0
urllib3==1.25.7 # via requests
idna==2.9 # via requests
requests==2.23.0 # via -r requirements/base.in
urllib3==1.25.9 # via requests
12 changes: 12 additions & 0 deletions requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# 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.

# When we went from httpretty 0.9.7 to 1.0.2, tests broke
httpretty<1.0.0
23 changes: 12 additions & 11 deletions requirements/test.in
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
-c constraints.txt

-r base.txt # Core dependencies for this package

coverage==4.3.1
ddt==1.1.1
nose==1.3.7
httpretty==0.8.14
pep8==1.7.0
pylint==1.9.4
pep257==0.7.0
mock==2.0.0
testfixtures==4.13.3
tox-travis==0.11
tox==3.7.0
coverage
ddt
httpretty
pycodestyle
pylint
pydocstyle
pytest
pytest-cov
mock
testfixtures
73 changes: 32 additions & 41 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,39 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# make upgrade
# pip-compile --output-file=requirements/test.txt requirements/test.in
#
astroid==1.6.6 # via pylint
backports.functools-lru-cache==1.6.1 # via astroid, isort, pylint
certifi==2019.11.28
chardet==3.0.4
configparser==4.0.2 # via importlib-metadata, pylint
contextlib2==0.6.0.post1 # via importlib-metadata
coverage==4.3.1
ddt==1.1.1
enum34==1.1.6 # via astroid
filelock==3.0.12 # via tox
funcsigs==1.0.2 # via mock
futures==3.3.0 # via isort
httpretty==0.8.14
idna==2.8
importlib-metadata==1.1.0 # via pluggy
astroid==2.4.1 # via pylint
attrs==19.3.0 # via pytest
certifi==2020.4.5.1 # via -r requirements/base.txt, requests
chardet==3.0.4 # via -r requirements/base.txt, requests
coverage==5.1 # via -r requirements/test.in, pytest-cov
ddt==1.3.1 # via -r requirements/test.in
httpretty==0.9.7 # via -c requirements/constraints.txt, -r requirements/test.in
idna==2.9 # via -r requirements/base.txt, requests
importlib-metadata==1.6.0 # via pluggy, pytest
isort==4.3.21 # via pylint
lazy-object-proxy==1.4.3 # via astroid
mccabe==0.6.1 # via pylint
mock==2.0.0
more-itertools==5.0.0 # via zipp
nose==1.3.7
pathlib2==2.3.5 # via importlib-metadata
pbr==5.4.4 # via mock
pep257==0.7.0
pep8==1.7.0
pluggy==0.13.1 # via tox
py==1.8.0 # via tox
pylint==1.9.4
requests==2.22.0
scandir==1.10.0 # via pathlib2
singledispatch==3.4.0.3 # via astroid, pylint
six==1.13.0 # via astroid, mock, more-itertools, pathlib2, pylint, singledispatch, tox
testfixtures==4.13.3
toml==0.10.0 # via tox
tox-travis==0.11
tox==3.7.0
urllib3==1.25.7
virtualenv==16.7.8 # via tox
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
mock==3.0.5 # via -r requirements/test.in
more-itertools==8.2.0 # via pytest
packaging==20.3 # via pytest
pathlib2==2.3.5 # via pytest
pluggy==0.13.1 # via pytest
py==1.8.1 # via pytest
pycodestyle==2.5.0 # via -r requirements/test.in
pydocstyle==5.0.2 # via -r requirements/test.in
pylint==2.5.2 # via -r requirements/test.in
pyparsing==2.4.7 # via packaging
pytest-cov==2.8.1 # via -r requirements/test.in
pytest==5.4.1 # via -r requirements/test.in, pytest-cov
requests==2.23.0 # via -r requirements/base.txt
six==1.14.0 # via astroid, httpretty, mock, packaging, pathlib2
snowballstemmer==2.0.0 # via pydocstyle
testfixtures==6.14.1 # via -r requirements/test.in
toml==0.10.0 # via pylint
typed-ast==1.4.1 # via astroid
urllib3==1.25.9 # via -r requirements/base.txt, requests
wcwidth==0.1.9 # via pytest
wrapt==1.12.1 # via astroid
zipp==1.2.0 # via importlib-metadata
4 changes: 4 additions & 0 deletions requirements/tox.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-c constraints.txt

tox
tox-travis
21 changes: 21 additions & 0 deletions requirements/tox.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# This file is autogenerated by pip-compile
# To update, run:
#
# make upgrade
#
appdirs==1.4.3 # via virtualenv
distlib==0.3.0 # via virtualenv
filelock==3.0.12 # via tox, virtualenv
importlib-metadata==1.6.0 # via importlib-resources, pluggy, tox, virtualenv
importlib-resources==1.5.0 # via virtualenv
packaging==20.3 # via tox
pluggy==0.13.1 # via tox
py==1.8.1 # via tox
pyparsing==2.4.7 # via packaging
six==1.14.0 # via packaging, tox, virtualenv
toml==0.10.0 # via tox
tox-travis==0.12 # via -r requirements/tox.in
tox==3.15.0 # via -r requirements/tox.in, tox-travis
virtualenv==20.0.20 # via tox
zipp==1.2.0 # via importlib-metadata, importlib-resources
41 changes: 27 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,29 @@
with codecs.open('README.rst', 'r', 'utf-8') as f:
LONG_DESCRIPTION = f.read()

def load_requirements(*requirements_paths):
"""
Load all requirements from the specified requirements files.
Returns a list of requirement strings.
"""
requirements = set()
for path in requirements_paths:
with open(path) as reqs:
requirements.update(
line.split('#')[0].strip() for line in reqs
if is_requirement(line.strip())
)
return list(requirements)


def is_requirement(line):
"""
Return True if the requirement line is a package requirement;
that is, it is not blank, a comment, a URL, or an included file.
"""
return line and not line.startswith(('-r', '#', '-e', 'git+', '-c'))


setup(
name='edx-analytics-data-api-client',
version=VERSION,
Expand All @@ -32,20 +55,10 @@
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
],
install_requires=[
"requests",
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.8',
],
tests_require=[
"coverage",
"nose",
"httpretty",
"pep8",
"pylint",
"pep257"
]
install_requires=load_requirements('requirements/base.in'),
test_requires=load_requirements('requirements/base.in')
)
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
[tox]
envlist = py27,py36
envlist = py{35,38}, quality

[testenv]
deps = -r{toxinidir}/requirements.txt
commands = make test quality
deps = -r{toxinidir}/requirements/test.txt
commands = make test
whitelist_externals = make

[testenv:quality]
deps = -r{toxinidir}/requirements/test.txt
commands = make quality

0 comments on commit fdb5aab

Please sign in to comment.