This repository was archived by the owner on Aug 15, 2022. It is now read-only.
Add tests and bugfix for b'' messages appearing in python3.#46
Merged
jammons merged 2 commits intoslack-samples:masterfrom Jun 5, 2016
Merged
Add tests and bugfix for b'' messages appearing in python3.#46jammons merged 2 commits intoslack-samples:masterfrom
jammons merged 2 commits intoslack-samples:masterfrom
Conversation
I added unicode and non-unicode message testing for the output() method
on RTMBot. I'm concerned about why the encode('ascii', 'ignore') was
there in the first place, but not having it seems to do the right
thing...
Contributor
Author
|
This fixes the same issue as in https://github.com/slackhq/python-rtmbot/pull/44/files and if the ascii encode is necessary, doing the decode is another solution to this problem. (I'd like to try to move to using utf8 in python 2.7, so maybe |
tests/test_rtmbot_core.py
Outdated
| rtmbot = init_rtmbot() | ||
|
|
||
| # Mock the slack_client object | ||
| slackclient_mock = Mock() |
Contributor
There was a problem hiding this comment.
You want to create_autospec here.
from slackclient import SlackClient
slackclient_mock = mock.create_autospec(SlackClient, spec_set=True)
For the above and all other mocks. This is going to save you from making a typo somewhere and actually ensure that you're writing tests against real methods. https://docs.python.org/3/library/unittest.mock.html#auto-speccing has a good write up on more details- happy to discuss further, since it took me a long while to grok!
This was referenced Jun 5, 2016
Closed
Strings should now be passed to the plugins as unicode values in py2.7 so we have to make sure that we don't convert those into ascii by using python str instead of u'' strings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I added unicode and non-unicode message testing for the output() method
on RTMBot. I'm concerned about why the encode('ascii', 'ignore') was
there in the first place, but not having it seems to do the right
thing...
Fixes: #45