Test updates (#314)

Test updates
This commit is contained in:
Hugo van Kemenade 2019-12-20 23:43:35 +02:00 committed by GitHub
commit 7d5947341b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 36 additions and 55 deletions

View file

@ -1,21 +1,21 @@
repos: repos:
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v1.24.0 rev: v1.25.2
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: ["--py3-plus"] args: ["--py3-plus"]
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 19.3b0 rev: 19.10b0
hooks: hooks:
- id: black - id: black
language_version: python3.7 args: ["--target-version", "py35"]
# override until resolved: https://github.com/psf/black/issues/402 # override until resolved: https://github.com/psf/black/issues/402
files: \.pyi?$ files: \.pyi?$
types: [] types: []
- repo: https://gitlab.com/pycqa/flake8 - repo: https://gitlab.com/pycqa/flake8
rev: 3.7.8 rev: 3.7.9
hooks: hooks:
- id: flake8 - id: flake8
additional_dependencies: [flake8-2020] additional_dependencies: [flake8-2020]
@ -24,14 +24,14 @@ repos:
rev: v4.3.21 rev: v4.3.21
hooks: hooks:
- id: isort - id: isort
language_version: python3.7
- repo: https://github.com/pre-commit/pygrep-hooks - repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.4.1 rev: v1.4.2
hooks: hooks:
- id: python-check-blanket-noqa - id: python-check-blanket-noqa
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0 rev: v2.4.0
hooks: hooks:
- id: check-merge-conflict
- id: check-yaml - id: check-yaml

View file

@ -1,5 +1,8 @@
language: python language: python
cache: pip cache:
pip: true
directories:
- $HOME/.cache/pre-commit
env: env:
global: global:
@ -15,32 +18,26 @@ env:
matrix: matrix:
fast_finish: true fast_finish: true
include: include:
- python: 3.7 - python: 3.8
env: TOXENV=lint env: TOXENV=lint
- python: 3.8
- python: 3.7 - python: 3.7
env: TOXENV=py37
- python: 3.6 - python: 3.6
env: TOXENV=py36
- python: 3.5 - python: 3.5
env: TOXENV=py35
- python: pypy3 - python: pypy3
env: TOXENV=pypy3
- python: 3.8-dev
env: TOXENV=py38dev
allow_failures:
- env: TOXENV=pypy3
install: install:
- travis_retry pip install --upgrade pip - travis_retry pip install -U pip
- travis_retry pip install --upgrade tox - travis_retry pip install -U tox-travis
- travis_retry pip install --upgrade coverage
script: tox script: tox
after_success: after_success:
- travis_retry pip install coveralls && coveralls - |
- travis_retry pip install codecov && codecov if [ "$TOXENV" != "lint" ]; then
- travis_retry pip install scrutinizer-ocular && ocular travis_retry pip install -U coveralls && coveralls
travis_retry pip install -U codecov && codecov
fi
deploy: deploy:
- provider: pypi - provider: pypi

View file

@ -1,4 +0,0 @@
Installation Instructions
=========================
Execute "python setup.py install" as a super user.

View file

@ -2,5 +2,4 @@ graft src
include setup.py include setup.py
include README.md include README.md
include COPYING include COPYING
include INSTALL
recursive-include tests *.py recursive-include tests *.py

View file

@ -3,6 +3,7 @@ pyLast
[![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.org/project/pylast/) [![PyPI version](https://img.shields.io/pypi/v/pylast.svg)](https://pypi.org/project/pylast/)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pylast.svg)](https://pypi.org/project/pylast/) [![Supported Python versions](https://img.shields.io/pypi/pyversions/pylast.svg)](https://pypi.org/project/pylast/)
[![PyPI downloads](https://img.shields.io/pypi/dm/pylast.svg)](https://pypistats.org/packages/pylast)
[![Build status](https://travis-ci.org/pylast/pylast.svg?branch=master)](https://travis-ci.org/pylast/pylast) [![Build status](https://travis-ci.org/pylast/pylast.svg?branch=master)](https://travis-ci.org/pylast/pylast)
[![Coverage (Codecov)](https://codecov.io/gh/pylast/pylast/branch/master/graph/badge.svg)](https://codecov.io/gh/pylast/pylast) [![Coverage (Codecov)](https://codecov.io/gh/pylast/pylast/branch/master/graph/badge.svg)](https://codecov.io/gh/pylast/pylast)
[![Coverage (Coveralls)](https://coveralls.io/repos/github/pylast/pylast/badge.svg?branch=master)](https://coveralls.io/github/pylast/pylast?branch=master) [![Coverage (Coveralls)](https://coveralls.io/repos/github/pylast/pylast/badge.svg?branch=master)](https://coveralls.io/github/pylast/pylast?branch=master)
@ -101,7 +102,7 @@ export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE
To run all unit and integration tests: To run all unit and integration tests:
```sh ```sh
pip install pytest flaky mock pip install pytest flaky
pytest pytest
``` ```

View file

@ -4,6 +4,3 @@ universal = 1
[flake8] [flake8]
ignore = W503 ignore = W503
max_line_length = 88 max_line_length = 88
[pycodestyle]
max_line_length = 88

View file

@ -20,15 +20,9 @@ setup(
author="Amr Hassan <amr.hassan@gmail.com> and Contributors", author="Amr Hassan <amr.hassan@gmail.com> and Contributors",
author_email="amr.hassan@gmail.com", author_email="amr.hassan@gmail.com",
url="https://github.com/pylast/pylast", url="https://github.com/pylast/pylast",
tests_require=[ extras_require={
"coverage", "tests": ["flaky", "pytest", "pytest-cov", "pytest-random-order", "pyyaml"]
"flaky", },
"mock",
"pycodestyle",
"pyflakes",
"pytest",
"pyyaml",
],
python_requires=">=3.5", python_requires=">=3.5",
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
@ -40,6 +34,7 @@ setup(
"Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy", "Programming Language :: Python :: Implementation :: PyPy",

View file

@ -36,9 +36,7 @@ from xml.dom import Node, minidom
from . import version from . import version
__author__ = "Amr Hassan, hugovk, Mice Pápai" __author__ = "Amr Hassan, hugovk, Mice Pápai"
__copyright__ = ( __copyright__ = "Copyright (C) 2008-2010 Amr Hassan, 2013-2019 hugovk, 2017 Mice Pápai"
"Copyright (C) 2008-2010 Amr Hassan, 2013-2019 hugovk, " "2017 Mice Pápai"
)
__license__ = "apache2" __license__ = "apache2"
__email__ = "amr.hassan@gmail.com" __email__ = "amr.hassan@gmail.com"
__version__ = version.__version__ __version__ = version.__version__
@ -903,7 +901,7 @@ class _Request:
headers = { headers = {
"Content-type": "application/x-www-form-urlencoded", "Content-type": "application/x-www-form-urlencoded",
"Accept-Charset": "utf-8", "Accept-Charset": "utf-8",
"User-Agent": "pylast" + "/" + __version__, "User-Agent": "pylast/" + __version__,
} }
(host_name, host_subdir) = self.network.ws_server (host_name, host_subdir) = self.network.ws_server

View file

@ -5,6 +5,7 @@ Integration (not unit) tests for pylast.py
import unittest import unittest
import pylast import pylast
import pytest
from .test_pylast import TestPyLastWithLastFm from .test_pylast import TestPyLastWithLastFm
@ -281,6 +282,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
# Assert # Assert
self.assertEqual(corrected_artist_name, "Guns N' Roses") self.assertEqual(corrected_artist_name, "Guns N' Roses")
@pytest.mark.xfail
def test_get_userplaycount(self): def test_get_userplaycount(self):
# Arrange # Arrange
artist = pylast.Artist("John Lennon", self.network, username=self.username) artist = pylast.Artist("John Lennon", self.network, username=self.username)

View file

@ -7,6 +7,7 @@ import unittest
import warnings import warnings
import pylast import pylast
import pytest
from .test_pylast import TestPyLastWithLastFm from .test_pylast import TestPyLastWithLastFm
@ -182,6 +183,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
# Assert # Assert
self.assertEqual(lastfm_user, loaded_user) self.assertEqual(lastfm_user, loaded_user)
@pytest.mark.xfail
def test_cacheable_user(self): def test_cacheable_user(self):
# Arrange # Arrange
lastfm_user = self.network.get_authenticated_user() lastfm_user = self.network.get_authenticated_user()

View file

@ -1,4 +1,5 @@
import mock from unittest import mock
import pylast import pylast
import pytest import pytest

11
tox.ini
View file

@ -1,21 +1,14 @@
[tox] [tox]
envlist = py37, py36, py35, pypy3, py38dev envlist = py38, py37, py36, py35, pypy3
recreate = False recreate = False
[testenv] [testenv]
extras = tests
setenv = setenv =
PYLAST_USERNAME={env:PYLAST_USERNAME:} PYLAST_USERNAME={env:PYLAST_USERNAME:}
PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:} PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:}
PYLAST_API_KEY={env:PYLAST_API_KEY:} PYLAST_API_KEY={env:PYLAST_API_KEY:}
PYLAST_API_SECRET={env:PYLAST_API_SECRET:} PYLAST_API_SECRET={env:PYLAST_API_SECRET:}
deps =
pyyaml
pytest
mock
ipdb
pytest-cov
pytest-random-order
flaky
commands = pytest -v -s -W all --cov pylast --cov-report term-missing --random-order {posargs} commands = pytest -v -s -W all --cov pylast --cov-report term-missing --random-order {posargs}
[testenv:venv] [testenv:venv]