Сама ошибка из кода вьюхи
Вьюха
@login_required
@route('/change_password/', methods=['POST'])
def change_password(self):
data = request.get_json()
if not bcrypt.check_password_hash(current_user.password, data['old']):
return return_response(404, jsonify(error='Старый пароль введен не верно'))
if not data['new'] == data['confirm']:
return return_response(404, jsonify(error='Новый пароль и подтверждение пароля не совпадают'))
try:
User.query.filter_by(id=current_user.id).update({
'password': bcrypt.generate_password_hash(data['new'])
})
db.session.commit()
except SQLAlchemyError as e:
return return_response(500, jsonify(error='Произошлка ошибка во время запроса.'))
return '', 200
ошибка
======================================================================
ERROR: test_change_password (__main__.LoginTest)
TEST: change password
----------------------------------------------------------------------
Traceback (most recent call last):
File "D:/coding/python/flask-cachlka/tests/base.py", line 61, in test_change_password
confirm='new'
File "D:\coding\venv\flask-cachlka\lib\site-packages\werkzeug\test.py", line 788, in post
return self.open(*args, **kw)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\testing.py", line 108, in open
follow_redirects=follow_redirects)
File "D:\coding\venv\flask-cachlka\lib\site-packages\werkzeug\test.py", line 751, in open
response = self.run_wsgi_app(environ, buffered=buffered)
File "D:\coding\venv\flask-cachlka\lib\site-packages\werkzeug\test.py", line 668, in run_wsgi_app
rv = run_wsgi_app(self.application, environ, buffered=buffered)
File "D:\coding\venv\flask-cachlka\lib\site-packages\werkzeug\test.py", line 871, in run_wsgi_app
app_rv = app(environ, start_response)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask_classy.py", line 200, in proxy
response = view(**request.view_args)
File "D:\coding\venv\flask-cachlka\lib\site-packages\flask_login.py", line 792, in decorated_view
return func(*args, **kwargs)
File "D:\coding\python\flask-cachlka\app\views.py", line 96, in change_password
if not bcrypt.check_password_hash(current_user.password, data['old']):
TypeError: 'NoneType' object is not subscriptable
----------------------------------------------------------------------
Ran 1 test in 1.181s
FAILED (errors=1)