praw-dev/praw — pull request #295 by jknabl (2014-05-04 18:54:35+00:00)
Title: Add delete_redditor functionality for AuthenticatedReddit class (#240)

AuthenticatedReddit now has a method delete_redditor which deletes the currently logged-in redditor.

Works when tested manually:

>>> import praw
>>> r = praw.Reddit('dsf', site_name='local')
>>> r.create_redditor('d_schrute', 'beets')
{u'errors': [], u'data': {u'modhash': u'd_schrute', u'cookie': u'1748,2014-05-04T14:28:05,81e7d58598850870c330fd35eb2b0a34d3102dfa'}}
>>> r.login('d_schrute', 'beets')
>>> r.user.name
'd_schrute'
>>> r.delete_redditor('beets')
{u'errors': []}
>>> r.clear_authentication()
>>> r.login('d_schrute', 'beets')
Traceback (most recent call last):
File "", line 1, in
File "praw/__init__.py", line 1212, in login
self.request_json(self.config['login'], data=data)
File "praw/decorators.py", line 177, in wrapped
raise error_list[0]
praw.errors.InvalidUserPass: `invalid password` on field `passwd`
>>> r.create_redditor('d_schrute', 'beets')
Traceback (most recent call last):
File "", line 1, in
File "praw/decorators.py", line 225, in wrapped
return function(obj, *args, **kwargs)
File "praw/__init__.py", line 664, in create_redditor
return self.request_json(self.config['register'], data=data)
File "praw/decorators.py", line 177, in wrapped
raise error_list[0]
praw.errors.APIException: (USERNAME_TAKEN_DEL) `that username is taken by a deleted account` on field `user`

And the test suites seem to work, if I'm doing it right:

>>> suite = unittest.TestSuite()
>>> suite.addTest(praw.tests.LocalOnlyTest('test_delete_existing_redditor'))
>>> suite.addTest(praw.tests.LocalOnlyTest('test_create_deleted_redditor'))
>>> suite.addTest(praw.tests.LocalOnlyTest('test_deleted_redditor_login'))
>>> unittest.TextTestRunner().run(suite)
Passing local only test: LocalOnlyTest.test_delete_existing_redditor
.Passing local only test: LocalOnlyTest.test_create_deleted_redditor
.Passing local only test: LocalOnlyTest.test_deleted_redditor_login
.
----------------------------------------------------------------------
Ran 3 tests in 12.830s

OK