Skip to content

Commit

Permalink
Only test write operations on a single Python version to avoid collis…
Browse files Browse the repository at this point in the history
…ion failures
  • Loading branch information
hugovk committed Jun 24, 2020
1 parent e7ad4ac commit 32461c0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
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

0 comments on commit 32461c0

Please sign in to comment.