

def test_photo_upload(self):
    nick = 'popular'
    nick = clean.nick(nick)
    old_avatar = api.actor_get(api.ROOT, nick).extra.get('icon', 'avatar_default')
    self.login(nick)
    f = open('testdata/test_avatar.jpg')
    r = self.client.post('/welcome/1', {
        'imgfile': f,
        '_nonce': util.create_nonce('popular', 'change_photo'),
    })
    r = r.assertRedirectsPrefix(r, '/welcome/1?')
    new_avatar = api.actor_get(api.ROOT, nick).extra.get('icon', 'avatar_default')
    self.assertNotEquals(old_avatar, new_avatar)
    self.assertContains(r, 'Avatar uploaded')
    self.assertTemplateUsed(r, 'join/templates/welcome_photo.html')
    self.assertTemplateUsed(r, 'common/templates/flash.html')

dataset/ETHPy150Open CollabQ/CollabQ/join/tests.py WelcomeTest.test_photo_upload/VarMisuse@93/131 `self`->`r`