python - nosetests/unittest still shows error when test passes? -


i have unit test tests if api point unaccessible if not authenticated this:

def test_endpoint_get_unauth(self):     r = self.get('/api/endpoint/1')     self.assertstatuscode(r, 401) 

the test passes, nosetests/unittest still shows me error exception raised saying "not authorized." there anyway stop this?

full log:

error in views [/myenv/lib/python2.7/site-packages/flask_restless/views.py:115]: not authorized -------------------------------------------------------------------------------- traceback (most recent call last):   file "/myapp/myenv/lib/python2.7/site-packages/flask_restless/views.py", line 113, in decorator     return func(*args, **kw)   file "/myapp/myenv/lib/python2.7/site-packages/flask/views.py", line 84, in view     return self.dispatch_request(*args, **kwargs)   file "/myapp/myenv/lib/python2.7/site-packages/flask/views.py", line 149, in dispatch_request     return meth(*args, **kwargs)   file "/myapp/myenv/lib/python2.7/site-packages/flask_restless/views.py", line 989, in     preprocessor(instance_id=instid)   file "/myapp/app/api/api.py", line 16, in check_auth     raise processingexception(message='not authorized', status_code=401) processingexception ................ ---------------------------------------------------------------------- ran 16 tests in 15.788s  ok 

the message see comes application logging.

"error" logging level of event, need set logger threshold higher.

assuming testcase object has app attribute test client app, if don't want see error message test, write:

def test_endpoint_get_unauth(self):     import logging     self.app.logger.setlevel(logging.critical)      r = self.get('/api/endpoint/1')     self.assertstatuscode(r, 401) 

for details see https://docs.python.org/2/library/logging.html


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -