From 53749592c8443f13879ea9264a22eea150ca9f47 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 15 Sep 2017 16:44:57 +0200 Subject: test: Make mock_weechat a dependency of realish_eventrouter Setting up the eventrouter for the tests involves code that requires the config object to be set, so it has to depend on mock_weechat. This didn't cause a problem when all the tests were run since the first test depends on mock_weechat so it would be set up. However, if you tried to run a single test that depended on realish_eventrouter, but not mock_weechat, it would fail. --- _pytest/conftest.py | 2 +- _pytest/test_linkifytext.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_pytest/conftest.py b/_pytest/conftest.py index 43d4a74..4f94983 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -26,7 +26,7 @@ def mock_websocket(): return fakewebsocket() @pytest.fixture -def realish_eventrouter(): +def realish_eventrouter(mock_weechat): e = EventRouter() context = e.store_context(SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"})) rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read() diff --git a/_pytest/test_linkifytext.py b/_pytest/test_linkifytext.py index 010a48b..56bf1b5 100644 --- a/_pytest/test_linkifytext.py +++ b/_pytest/test_linkifytext.py @@ -6,7 +6,7 @@ from wee_slack import linkify_text # assert False -def test_linkifytext_does_partial_html_entity_encoding(mock_weechat, realish_eventrouter): +def test_linkifytext_does_partial_html_entity_encoding(realish_eventrouter): team = realish_eventrouter.teams.values()[0] channel = team.channels.values()[0] -- cgit From 3018160e71cf2c2623b0f4d887ce4780c888ab35 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 15 Sep 2017 16:50:30 +0200 Subject: test: Empty eventrouter queue when initializing it The commit 6718e2f added some more events to the queue when a buffer is created. This made some tests fail as it would process these events instead of the ones added in the tests. Fix it by processing all events in the queue when setting up the eventrouter for the tests. --- _pytest/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_pytest/conftest.py b/_pytest/conftest.py index 4f94983..232814f 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -31,7 +31,8 @@ def realish_eventrouter(mock_weechat): context = e.store_context(SlackRequest('xoxoxoxox', "rtm.start", {"meh": "blah"})) rtmstartdata = open('_pytest/data/http/rtm.start.json', 'r').read() e.receive_httprequest_callback(context, 1, 0, rtmstartdata, 4) - e.handle_next() + while len(e.queue): + e.handle_next() #e.sc is just shortcuts to these items e.sc = {} e.sc["team_id"] = e.teams.keys()[0] -- cgit From 6419730f7d18c711357c10dcbd5345fb75e57dee Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 15 Sep 2017 16:53:33 +0200 Subject: test: Fix two incorrect test names --- _pytest/test_everything.py | 2 +- _pytest/test_processteamjoin.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/_pytest/test_everything.py b/_pytest/test_everything.py index a121541..14625a6 100644 --- a/_pytest/test_everything.py +++ b/_pytest/test_everything.py @@ -4,7 +4,7 @@ import json #from wee_slack import render from wee_slack import ProcessNotImplemented -def test_process_message(monkeypatch, realish_eventrouter, mock_websocket): +def test_everything(monkeypatch, realish_eventrouter, mock_websocket): eventrouter = realish_eventrouter diff --git a/_pytest/test_processteamjoin.py b/_pytest/test_processteamjoin.py index 00a8b4c..68a9072 100644 --- a/_pytest/test_processteamjoin.py +++ b/_pytest/test_processteamjoin.py @@ -3,7 +3,7 @@ import json from wee_slack import ProcessNotImplemented -def test_process_reply(monkeypatch, mock_websocket, realish_eventrouter): +def test_process_team_join(monkeypatch, mock_websocket, realish_eventrouter): eventrouter = realish_eventrouter -- cgit From 20031138aa96aa404312f228d042d3169320136d Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Fri, 15 Sep 2017 16:56:09 +0200 Subject: test: Remove monkeypatch dependency As far as I can see, this isn't used anywhere. --- _pytest/test_everything.py | 2 +- _pytest/test_presencechange.py | 2 +- _pytest/test_process_message.py | 2 +- _pytest/test_processreply.py | 2 +- _pytest/test_processteamjoin.py | 2 +- _pytest/test_sendmessage.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/_pytest/test_everything.py b/_pytest/test_everything.py index 14625a6..c85fc15 100644 --- a/_pytest/test_everything.py +++ b/_pytest/test_everything.py @@ -4,7 +4,7 @@ import json #from wee_slack import render from wee_slack import ProcessNotImplemented -def test_everything(monkeypatch, realish_eventrouter, mock_websocket): +def test_everything(realish_eventrouter, mock_websocket): eventrouter = realish_eventrouter diff --git a/_pytest/test_presencechange.py b/_pytest/test_presencechange.py index b4202fa..4e02640 100644 --- a/_pytest/test_presencechange.py +++ b/_pytest/test_presencechange.py @@ -1,5 +1,5 @@ -def test_PresenceChange(monkeypatch, realish_eventrouter, mock_websocket): +def test_PresenceChange(realish_eventrouter, mock_websocket): e = realish_eventrouter diff --git a/_pytest/test_process_message.py b/_pytest/test_process_message.py index e2447f7..2e0b31e 100644 --- a/_pytest/test_process_message.py +++ b/_pytest/test_process_message.py @@ -2,7 +2,7 @@ import json from wee_slack import render -def test_process_message(monkeypatch, realish_eventrouter, mock_websocket): +def test_process_message(realish_eventrouter, mock_websocket): e = realish_eventrouter diff --git a/_pytest/test_processreply.py b/_pytest/test_processreply.py index a725f23..041a1db 100644 --- a/_pytest/test_processreply.py +++ b/_pytest/test_processreply.py @@ -1,6 +1,6 @@ #from wee_slack import process_reply -def test_process_reply(monkeypatch, realish_eventrouter, mock_websocket): +def test_process_reply(realish_eventrouter, mock_websocket): e = realish_eventrouter diff --git a/_pytest/test_processteamjoin.py b/_pytest/test_processteamjoin.py index 68a9072..c7c199f 100644 --- a/_pytest/test_processteamjoin.py +++ b/_pytest/test_processteamjoin.py @@ -3,7 +3,7 @@ import json from wee_slack import ProcessNotImplemented -def test_process_team_join(monkeypatch, mock_websocket, realish_eventrouter): +def test_process_team_join(mock_websocket, realish_eventrouter): eventrouter = realish_eventrouter diff --git a/_pytest/test_sendmessage.py b/_pytest/test_sendmessage.py index a87942d..42c22a6 100644 --- a/_pytest/test_sendmessage.py +++ b/_pytest/test_sendmessage.py @@ -1,5 +1,5 @@ -def test_send_message(monkeypatch, realish_eventrouter, mock_websocket): +def test_send_message(realish_eventrouter, mock_websocket): e = realish_eventrouter t = e.teams.keys()[0] -- cgit