Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'NoneType' object has no attribute 'replace' #431

Closed
alexandrul opened this issue Jun 13, 2016 · 3 comments
Closed

AttributeError: 'NoneType' object has no attribute 'replace' #431

alexandrul opened this issue Jun 13, 2016 · 3 comments

Comments

@alexandrul
Copy link

alexandrul commented Jun 13, 2016

Hi,

test_client_basic_auth is considered passed even if it raises an exception:

[2016-06-08 12:29:56,811] ERROR in app: Exception on /basic_auth [GET]
Traceback (most recent call last):
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/travis/build/locustio/locust/.tox/py35/lib/python3.5/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/travis/build/locustio/locust/locust/test/testcases.py", line 84, in basic_auth
    auth = base64.b64decode(request.headers.get("Authorization").replace("Basic ", "")).decode('utf-8')
AttributeError: 'NoneType' object has no attribute 'replace'
@alexandrul
Copy link
Author

This change works for me:

auth = base64.b64decode(request.headers.get("Authorization", '').replace("Basic ", "")).decode('utf-8')

@heyman heyman closed this as completed in 2d11678 Jun 13, 2016
@heyman
Copy link
Member

heyman commented Jun 13, 2016

Thanks!

@alexandrul
Copy link
Author

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants