diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index da1e286..4ddbb33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/tests/test_artist.py b/tests/test_artist.py index 8250f5b..802a5e2 100755 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -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 diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 83a64ad..730d39d 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -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 diff --git a/tests/test_user.py b/tests/test_user.py index b0ae898..7f7e2e9 100755 --- a/tests/test_user.py +++ b/tests/test_user.py @@ -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 diff --git a/tox.ini b/tox.ini index 87367e0..0a61ca1 100644 --- a/tox.ini +++ b/tox.ini @@ -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