Merge pull request #342 from pylast/cover-tests

Include tests in coverage
This commit is contained in:
mergify[bot] 2020-08-22 09:09:49 +00:00 committed by GitHub
commit 77c17a9c36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 31 deletions

View file

@ -1,6 +1,6 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.6.1
rev: v2.7.2
hooks:
- id: pyupgrade
args: ["--py3-plus"]
@ -26,17 +26,17 @@ repos:
- id: seed-isort-config
- repo: https://github.com/timothycrosley/isort
rev: 4.3.21
rev: 5.4.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.5.1
rev: v1.6.0
hooks:
- id: python-check-blanket-noqa
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.1.0
rev: v3.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml

View file

@ -153,11 +153,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
# Assert
tags = artist.get_tags()
assert len(tags) > 0
found = False
for tag in tags:
if tag.name == "testing":
found = True
break
found = any(tag.name == "testing" for tag in tags)
assert found
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
@ -172,11 +168,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
# Assert
tags = artist.get_tags()
found = False
for tag in tags:
if tag.name == "testing":
found = True
break
found = any(tag.name == "testing" for tag in tags)
assert not found
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
@ -191,11 +183,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
# Assert
tags = artist.get_tags()
found = False
for tag in tags:
if tag.name == "testing":
found = True
break
found = any(tag.name == "testing" for tag in tags)
assert not found
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
@ -213,12 +201,8 @@ class TestPyLastArtist(TestPyLastWithLastFm):
# Assert
tags_after = artist.get_tags()
assert len(tags_after) == len(tags_before) - 2
found1, found2 = False, False
for tag in tags_after:
if tag.name == "removetag1":
found1 = True
elif tag.name == "removetag2":
found2 = True
found1 = any(tag.name == "removetag1" for tag in tags_after)
found2 = any(tag.name == "removetag2" for tag in tags_after)
assert not found1
assert not found2
@ -308,4 +292,4 @@ class TestPyLastArtist(TestPyLastWithLastFm):
playcount = artist.get_userplaycount()
# Assert
assert playcount >= 0
assert playcount >= 0 # whilst xfail: # pragma: no cover

View file

@ -13,7 +13,7 @@ from flaky import flaky
WRITE_TEST = sys.version_info[:2] == (3, 8)
def load_secrets():
def load_secrets(): # pragma: no cover
secrets_file = "test_pylast.yaml"
if os.path.isfile(secrets_file):
import yaml # pip install pyyaml

View file

@ -68,7 +68,7 @@ class TestPyLastUser(TestPyLastWithLastFm):
if int(registered):
# Last.fm API broken? Used to be yyyy-mm-dd not Unix timestamp
assert registered == "1037793040"
else:
else: # pragma: no cover
# Old way
# Just check date because of timezones
assert "2002-11-20 " in registered
@ -192,8 +192,13 @@ class TestPyLastUser(TestPyLastWithLastFm):
# Act/Assert
self.helper_validate_cacheable(lastfm_user, "get_friends")
self.helper_validate_cacheable(lastfm_user, "get_loved_tracks")
self.helper_validate_cacheable(lastfm_user, "get_recent_tracks")
# no cover whilst xfail:
self.helper_validate_cacheable( # pragma: no cover
lastfm_user, "get_loved_tracks"
)
self.helper_validate_cacheable( # pragma: no cover
lastfm_user, "get_recent_tracks"
)
def test_user_get_top_tags_with_limit(self):
# Arrange

View file

@ -8,7 +8,7 @@ setenv =
PYLAST_PASSWORD_HASH={env:PYLAST_PASSWORD_HASH:}
PYLAST_API_KEY={env:PYLAST_API_KEY:}
PYLAST_API_SECRET={env:PYLAST_API_SECRET:}
commands = pytest -v -s -W all --cov pylast --cov-report term-missing --random-order {posargs}
commands = pytest -v -s -W all --cov pylast --cov tests --cov-report term-missing --random-order {posargs}
[testenv:venv]
deps = ipdb