Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only test write operations on a single Python version to avoid collision failures #333

Merged
merged 1 commit into from Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/test_artist.py
Expand Up @@ -5,7 +5,7 @@
import pylast
import pytest

from .test_pylast import TestPyLastWithLastFm
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm


class TestPyLastArtist(TestPyLastWithLastFm):
Expand Down Expand Up @@ -141,6 +141,7 @@ def test_artist_listener_count(self):
assert isinstance(count, int)
assert count > 0

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_tag_artist(self):
# Arrange
artist = self.network.get_artist("Test Artist")
Expand All @@ -159,6 +160,7 @@ def test_tag_artist(self):
break
assert found

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_remove_tag_of_type_text(self):
# Arrange
tag = "testing" # text
Expand All @@ -177,6 +179,7 @@ def test_remove_tag_of_type_text(self):
break
assert not found

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_remove_tag_of_type_tag(self):
# Arrange
tag = pylast.Tag("testing", self.network) # Tag
Expand All @@ -195,6 +198,7 @@ def test_remove_tag_of_type_tag(self):
break
assert not found

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_remove_tags(self):
# Arrange
tags = ["removetag1", "removetag2"]
Expand All @@ -218,6 +222,7 @@ def test_remove_tags(self):
assert not found1
assert not found2

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_set_tags(self):
# Arrange
tags = ["sometag1", "sometag2"]
Expand Down
5 changes: 3 additions & 2 deletions tests/test_network.py
Expand Up @@ -8,11 +8,11 @@
import pylast
import pytest

from .test_pylast import PY37, TestPyLastWithLastFm
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm


class TestPyLastNetwork(TestPyLastWithLastFm):
@pytest.mark.skipif(not PY37, reason="Only run on Python 3.7 to avoid collisions")
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_scrobble(self):
# Arrange
artist = "test artist"
Expand All @@ -30,6 +30,7 @@ def test_scrobble(self):
assert str(last_scrobble.track.artist).lower() == artist
assert str(last_scrobble.track.title).lower() == title

@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_update_now_playing(self):
# Arrange
artist = "Test Artist"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pylast.py
Expand Up @@ -10,7 +10,7 @@
import pytest
from flaky import flaky

PY37 = sys.version_info[:2] == (3, 7)
WRITE_TEST = sys.version_info[:2] == (3, 8)


def load_secrets():
Expand Down
5 changes: 3 additions & 2 deletions tests/test_track.py
Expand Up @@ -7,10 +7,11 @@
import pylast
import pytest

from .test_pylast import PY37, TestPyLastWithLastFm
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm


class TestPyLastTrack(TestPyLastWithLastFm):
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_love(self):
# Arrange
artist = "Test Artist"
Expand All @@ -26,7 +27,7 @@ def test_love(self):
assert str(loved[0].track.artist).lower() == "test artist"
assert str(loved[0].track.title).lower() == "test title"

@pytest.mark.skipif(not PY37, reason="Only run on Python 3.7 to avoid collisions")
@pytest.mark.skipif(not WRITE_TEST, reason="Only test once to avoid collisions")
def test_unlove(self):
# Arrange
artist = pylast.Artist("Test Artist", self.network)
Expand Down