Fix pytest "Applying marks directly to parameters" deprecation

This commit is contained in:
Mads Marquart
2018-12-09 15:02:48 +01:00
parent 89a277c354
commit 3443a233f4
5 changed files with 24 additions and 14 deletions

View File

@@ -20,7 +20,9 @@ def group(pytestconfig):
return {"id": load_variable("group_id", pytestconfig.cache), "type": ThreadType.GROUP} return {"id": load_variable("group_id", pytestconfig.cache), "type": ThreadType.GROUP}
@pytest.fixture(scope="session", params=["user", "group", pytest.mark.xfail("none")]) @pytest.fixture(scope="session", params=[
"user", "group", pytest.param("none", marks=[pytest.mark.xfail()])
])
def thread(request, user, group): def thread(request, user, group):
return { return {
"user": user, "user": user,

View File

@@ -11,8 +11,14 @@ from time import time
@pytest.fixture(scope="module", params=[ @pytest.fixture(scope="module", params=[
Plan(int(time()) + 100, random_hex()), Plan(int(time()) + 100, random_hex()),
pytest.mark.xfail(Plan(int(time()), random_hex()), raises=FBchatFacebookError), pytest.param(
pytest.mark.xfail(Plan(0, None)), Plan(int(time()), random_hex()),
marks=[pytest.mark.xfail(raises=FBchatFacebookError)]
),
pytest.param(
Plan(0, None),
marks=[pytest.mark.xfail()],
),
]) ])
def plan_data(request, client, user, thread, catch_event, compare): def plan_data(request, client, user, thread, catch_event, compare):
with catch_event("onPlanCreated") as x: with catch_event("onPlanCreated") as x:

View File

@@ -26,7 +26,9 @@ from utils import random_hex, subset
PollOption(random_hex()), PollOption(random_hex()),
PollOption(random_hex()), PollOption(random_hex()),
]), ]),
pytest.mark.xfail(Poll(title=None, options=[]), raises=ValueError), pytest.param(
Poll(title=None, options=[]), marks=[pytest.mark.xfail(raises=ValueError)]
),
]) ])
def poll_data(request, client1, group, catch_event): def poll_data(request, client1, group, catch_event):
with catch_event("onPollCreated") as x: with catch_event("onPollCreated") as x:

View File

@@ -72,8 +72,8 @@ def test_change_nickname(client, client_all, catch_event, compare):
"😂", "😂",
"😕", "😕",
"😍", "😍",
pytest.mark.xfail("🙃", raises=FBchatFacebookError), pytest.param("🙃", marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.mark.xfail("not an emoji", raises=FBchatFacebookError) pytest.param("not an emoji", marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
]) ])
def test_change_emoji(client, catch_event, compare, emoji): def test_change_emoji(client, catch_event, compare, emoji):
with catch_event("onEmojiChange") as x: with catch_event("onEmojiChange") as x:
@@ -101,7 +101,7 @@ def test_change_image_remote(client1, group, catch_event):
[ [
x x
if x in [ThreadColor.MESSENGER_BLUE, ThreadColor.PUMPKIN] if x in [ThreadColor.MESSENGER_BLUE, ThreadColor.PUMPKIN]
else pytest.mark.expensive(x) else pytest.param(x, marks=[pytest.mark.expensive()])
for x in ThreadColor for x in ThreadColor
], ],
) )

View File

@@ -23,15 +23,15 @@ EMOJI_LIST = [
("😆", EmojiSize.LARGE), ("😆", EmojiSize.LARGE),
# These fail in `catch_event` because the emoji is made into a sticker # These fail in `catch_event` because the emoji is made into a sticker
# This should be fixed # This should be fixed
pytest.mark.xfail((None, EmojiSize.SMALL)), pytest.param(None, EmojiSize.SMALL, marks=[pytest.mark.xfail()]),
pytest.mark.xfail((None, EmojiSize.MEDIUM)), pytest.param(None, EmojiSize.MEDIUM, marks=[pytest.mark.xfail()]),
pytest.mark.xfail((None, EmojiSize.LARGE)), pytest.param(None, EmojiSize.LARGE, marks=[pytest.mark.xfail()]),
] ]
STICKER_LIST = [ STICKER_LIST = [
Sticker("767334476626295"), Sticker("767334476626295"),
pytest.mark.xfail(Sticker("0"), raises=FBchatFacebookError), pytest.param(Sticker("0"), marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.mark.xfail(Sticker(None), raises=FBchatFacebookError), pytest.param(Sticker(None), marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
] ]
TEXT_LIST = [ TEXT_LIST = [
@@ -40,8 +40,8 @@ TEXT_LIST = [
"\\\n\t%?&'\"", "\\\n\t%?&'\"",
"ˁҭʚ¹Ʋջوװ՞ޱɣࠚԹБɑȑңКએ֭ʗыԈٌʼőԈ×௴nચϚࠖణٔє܅Ԇޑط", "ˁҭʚ¹Ʋջوװ՞ޱɣࠚԹБɑȑңКએ֭ʗыԈٌʼőԈ×௴nચϚࠖణٔє܅Ԇޑط",
"a" * 20000, # Maximum amount of characters you can send "a" * 20000, # Maximum amount of characters you can send
pytest.mark.xfail("a" * 20001, raises=FBchatFacebookError), pytest.param("a" * 20001, marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.mark.xfail(None, raises=FBchatFacebookError), pytest.param(None, marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
] ]