diff options
author | Tollef Fog Heen <tfheen@err.no> | 2016-11-11 07:45:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-11 07:45:51 +0100 |
commit | 1bc423a87baf4f2eede8974cd7a2f3f6b29aaebf (patch) | |
tree | 008c299406953617f70f8958f5b642f55319b94b | |
parent | 16321569af9def448bd8a19f14ac115a63ff897d (diff) | |
parent | b610bfae9230a954fd4547c8ef0ef28036d8eccc (diff) | |
download | wee-slack-1bc423a87baf4f2eede8974cd7a2f3f6b29aaebf.tar.gz |
Merge pull request #278 from mattrobenolt/parametrize
Leverage pytest.parametrize for test_unfurl
-rw-r--r-- | _pytest/test_unfurl.py | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/_pytest/test_unfurl.py b/_pytest/test_unfurl.py index 2b80eda..2168aed 100644 --- a/_pytest/test_unfurl.py +++ b/_pytest/test_unfurl.py @@ -1,36 +1,41 @@ import wee_slack import pytest -import json slack = wee_slack -unfurl_map = [ - { "input": "foo", - "output": "foo", + +@pytest.mark.parametrize('case', ( + { + 'input': "foo", + 'output': "foo", }, - { "input": "<@U2147483697|@othernick>: foo", - "output": "@testuser: foo", - "ignore_alt_text": True + { + 'input': "<@U2147483697|@othernick>: foo", + 'output': "@testuser: foo", + 'ignore_alt_text': True, }, - { "input": "foo <#C2147483705|#otherchannel> foo", - "output": "foo #otherchannel foo", + { + 'input': "foo <#C2147483705|#otherchannel> foo", + 'output': "foo #otherchannel foo", }, - { "input": "foo <#C2147483705> foo", - "output": "foo #testchan foo", + { + 'input': "foo <#C2147483705> foo", + 'output': "foo #testchan foo", }, - { "input": "url: <https://example.com|example> suffix", - "output": "url: https://example.com (example) suffix", + { + 'input': "url: <https://example.com|example> suffix", + 'output': "url: https://example.com (example) suffix", }, - { "input": "url: <https://example.com|example with spaces> suffix", - "output": "url: https://example.com (example with spaces) suffix", + { + 'input': "url: <https://example.com|example with spaces> suffix", + 'output': "url: https://example.com (example with spaces) suffix", }, - { "input": "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>", - "output": "@othernick multiple unfurl https://example.com (example with spaces)", + { + 'input': "<@U2147483697|@othernick> multiple unfurl <https://example.com|example with spaces>", + 'output': "@othernick multiple unfurl https://example.com (example with spaces)", }, - ] - - -def test_unfurl_refs(myservers, mychannels, myusers): +)) +def test_unfurl_refs(myservers, mychannels, myusers, case): slack.servers = myservers slack.channels = mychannels slack.users = myusers @@ -38,8 +43,4 @@ def test_unfurl_refs(myservers, mychannels, myusers): slack.servers[0].users = myusers print mychannels[0].identifier - for k in unfurl_map: - if "ignore_alt_text" in k: - assert slack.unfurl_refs(k["input"], ignore_alt_text=k["ignore_alt_text"]) == k["output"] - else: - assert slack.unfurl_refs(k["input"]) == k["output"] + assert slack.unfurl_refs(case['input'], ignore_alt_text=case.get('ignore_alt_text', False)) == case['output'] |