Skip to content

Commit

Permalink
Merge pull request #367 from carpedm20/fix-pytest-deprecation
Browse files Browse the repository at this point in the history
Fix pytest "Applying marks directly to parameters" deprecation
  • Loading branch information
madsmtm authored Dec 9, 2018
2 parents 89a277c + 3443a23 commit b650f7e
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def group(pytestconfig):
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):
return {
"user": user,
Expand Down
10 changes: 8 additions & 2 deletions tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

@pytest.fixture(scope="module", params=[
Plan(int(time()) + 100, random_hex()),
pytest.mark.xfail(Plan(int(time()), random_hex()), raises=FBchatFacebookError),
pytest.mark.xfail(Plan(0, None)),
pytest.param(
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):
with catch_event("onPlanCreated") as x:
Expand Down
4 changes: 3 additions & 1 deletion tests/test_polls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
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):
with catch_event("onPollCreated") as x:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_thread_interraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_change_nickname(client, client_all, catch_event, compare):
"😂",
"😕",
"😍",
pytest.mark.xfail("🙃", raises=FBchatFacebookError),
pytest.mark.xfail("not an emoji", raises=FBchatFacebookError)
pytest.param("🙃", marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.param("not an emoji", marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
])
def test_change_emoji(client, catch_event, compare, emoji):
with catch_event("onEmojiChange") as x:
Expand Down Expand Up @@ -101,7 +101,7 @@ def test_change_image_remote(client1, group, catch_event):
[
x
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
],
)
Expand Down
14 changes: 7 additions & 7 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
("😆", EmojiSize.LARGE),
# These fail in `catch_event` because the emoji is made into a sticker
# This should be fixed
pytest.mark.xfail((None, EmojiSize.SMALL)),
pytest.mark.xfail((None, EmojiSize.MEDIUM)),
pytest.mark.xfail((None, EmojiSize.LARGE)),
pytest.param(None, EmojiSize.SMALL, marks=[pytest.mark.xfail()]),
pytest.param(None, EmojiSize.MEDIUM, marks=[pytest.mark.xfail()]),
pytest.param(None, EmojiSize.LARGE, marks=[pytest.mark.xfail()]),
]

STICKER_LIST = [
Sticker("767334476626295"),
pytest.mark.xfail(Sticker("0"), raises=FBchatFacebookError),
pytest.mark.xfail(Sticker(None), raises=FBchatFacebookError),
pytest.param(Sticker("0"), marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.param(Sticker(None), marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
]

TEXT_LIST = [
Expand All @@ -40,8 +40,8 @@
"\\\n\t%?&'\"",
"ˁҭʚ¹Ʋջوװ՞ޱɣࠚԹБɑȑңКએ֭ʗыԈٌʼőԈ×௴nચϚࠖణٔє܅Ԇޑط",
"a" * 20000, # Maximum amount of characters you can send
pytest.mark.xfail("a" * 20001, raises=FBchatFacebookError),
pytest.mark.xfail(None, raises=FBchatFacebookError),
pytest.param("a" * 20001, marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
pytest.param(None, marks=[pytest.mark.xfail(raises=FBchatFacebookError)]),
]


Expand Down

0 comments on commit b650f7e

Please sign in to comment.