These are chat archives for praw-dev/praw
PRAW, an acronym for "Python Reddit API Wrapper", is a python package that allows for simple access to reddit's API.
All that is needed to generate the cassette is
withstatement along the lines of
self.reddit.read_only = False
As an example, this is a test that I wrote (the three important lines highlighted): https://github.com/praw-dev/praw/blob/36f32102b395e43a4a9da1d1c461bf4696f10686/tests/integration/models/test_preferences.py#L17-L19
The first line sets
self.reddit.read_only = False because the action the test performs requires reading account-specific information. The second line tells Betamax to use the cassette, and the third line, inside the
with block, makes requests to the network.
withblock, which means that you don't have to do anything special to record a cassette other than running the test suite.
When recording, instead of running tests as
python setup.py test, run as
prawtest_client_id=whatever prawtest_client_secret=something prawtest_password=yourpassword prawtest_username=yourusername python setup.py test
(that's all one line)
The docs suggest an alternate method, which is to do
export prawtest_client_id=myclientid export prawtest_client_secret=myclientsecret export prawtest_password=mypassword export prawtest_test_subreddit=reddit_api_test export prawtest_username=myusername export prawtest_user_agent=praw_pytest
And then just run as
python setup.py test
for emoji_name, emoji_data in subreddit.emoji:
for emoji_name, emoji_data in subreddit.emojishould error out because subreddit.emoji yields one item at a time
for emoji in subreddit.emoji:
E AttributeError: 'str' object has no attribute '_reddit'
response = self.subreddit.fullname._reddit.get( API_PATH['emoji_list'].format(subreddit=self.subreddit))
E NameError: name 'Emoji' is not defined
assert isinstance(emoji, Emoji)
gitinstalled locally, it's probably easier to commit and push that way. But you can upload the cassette and commit on GH web also if you want.