Merge pull request #333 from pylast/isolate-write-tests

Only test write operations on a single Python version to avoid collision failures
This commit is contained in:
Hugo van Kemenade 2020-06-25 08:27:01 +03:00 committed by GitHub
commit 6f2bdb5db8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 6 deletions

View file

@ -5,7 +5,7 @@ Integration (not unit) tests for pylast.py
import pylast
import pytest
from .test_pylast import TestPyLastWithLastFm
from .test_pylast import WRITE_TEST, TestPyLastWithLastFm
class TestPyLastArtist(TestPyLastWithLastFm):
@ -141,6 +141,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
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")
@ -159,6 +160,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
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
@ -177,6 +179,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
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
@ -195,6 +198,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
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"]
@ -218,6 +222,7 @@ class TestPyLastArtist(TestPyLastWithLastFm):
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"]

View file

@ -8,11 +8,11 @@ import time
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"
@ -30,6 +30,7 @@ class TestPyLastNetwork(TestPyLastWithLastFm):
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"

View file

@ -10,7 +10,7 @@ import pylast
import pytest
from flaky import flaky
PY37 = sys.version_info[:2] == (3, 7)
WRITE_TEST = sys.version_info[:2] == (3, 8)
def load_secrets():

View file

@ -7,10 +7,11 @@ import time
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"
@ -26,7 +27,7 @@ class TestPyLastTrack(TestPyLastWithLastFm):
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)