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

View file

@ -1,5 +1,8 @@
language: python
cache: pip
cache:
pip: true
directories:
- $HOME/.cache/pre-commit
env:
global:
@ -15,32 +18,26 @@ env:
matrix:
fast_finish: true
include:
- python: 3.7
- python: 3.8
env: TOXENV=lint
- python: 3.8
- python: 3.7
env: TOXENV=py37
- python: 3.6
env: TOXENV=py36
- python: 3.5
env: TOXENV=py35
- python: pypy3
env: TOXENV=pypy3
- python: 3.8-dev
env: TOXENV=py38dev
allow_failures:
- env: TOXENV=pypy3
install:
- travis_retry pip install --upgrade pip
- travis_retry pip install --upgrade tox
- travis_retry pip install --upgrade coverage
- travis_retry pip install -U pip
- travis_retry pip install -U tox-travis
script: tox
after_success:
- travis_retry pip install coveralls && coveralls
- travis_retry pip install codecov && codecov
- travis_retry pip install scrutinizer-ocular && ocular
- |
if [ "$TOXENV" != "lint" ]; then
travis_retry pip install -U coveralls && coveralls
travis_retry pip install -U codecov && codecov
fi
deploy:
- 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 README.md
include COPYING
include INSTALL
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/)
[![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)
[![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)
@ -101,7 +102,7 @@ export PYLAST_API_SECRET=TODO_ENTER_YOURS_HERE
To run all unit and integration tests:
```sh
pip install pytest flaky mock
pip install pytest flaky
pytest
```

View file

@ -4,6 +4,3 @@ universal = 1
[flake8]
ignore = W503
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_email="amr.hassan@gmail.com",
url="https://github.com/pylast/pylast",
tests_require=[
"coverage",
"flaky",
"mock",
"pycodestyle",
"pyflakes",
"pytest",
"pyyaml",
],
extras_require={
"tests": ["flaky", "pytest", "pytest-cov", "pytest-random-order", "pyyaml"]
},
python_requires=">=3.5",
classifiers=[
"Development Status :: 5 - Production/Stable",
@ -40,6 +34,7 @@ setup(
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",

View file

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

View file

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

View file

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

View file

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

11
tox.ini
View file

@ -1,21 +1,14 @@
[tox]
envlist = py37, py36, py35, pypy3, py38dev
envlist = py38, py37, py36, py35, pypy3
recreate = False
[testenv]
extras = tests
setenv =
PYLAST_USERNAME={env:PYLAST_USERNAME:}
PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:}
PYLAST_API_KEY={env:PYLAST_API_KEY:}
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}
[testenv:venv]