'Upload a valid avatar.'

def test_upload_avatar(self):

    user_profile = Profile.objects.get(user__username=self.u.username)
    with open('kitsune/upload/tests/media/test.jpg') as f:
        user_profile.avatar.save('test_old.jpg', File(f), save=True)
    assert user_profile.avatar.name.endswith('92b516.jpg')
    old_path = user_profile.avatar.path
    assert os.path.exists(old_path), 'Old    avatar    is    not    in    place.'
    url = reverse('users.edit_avatar')
    self.client.login(username=self.u.username, password='testpass')
    with open('kitsune/upload/tests/media/test.jpg') as f:
        r = self.client.post(url, {'avatar': f})
    eq_(302, r.status_code)
    eq_(('http://testserver/en-US' + reverse('users.edit_my_profile')), r['location'])
    assert (not os.path.exists(old_path)), 'Old    avatar    was    not    removed.'
