corydolphin / flask-cors

Cross Origin Resource Sharing ( CORS ) support for Flask
https://flask-cors.corydolphin.com/
MIT License
877 stars 137 forks source link

Test fails in test_acl_uncaught_exception_500 with Flask 1.1.0 #253

Closed czerw closed 4 years ago

czerw commented 4 years ago

Build test started to fail after Flask update to 1.1.0. Failure is not dependent on python version(2/3). Last working Flask version was 1.0.4.

[  133s] FAIL: test_acl_uncaught_exception_500 (tests.decorator.test_exception_interception.NoExceptionInterceptionTestCase)
[  133s] NoExceptionInterceptionTestCase.test_acl_uncaught_exception_500
[  133s] ----------------------------------------------------------------------
[  133s] Traceback (most recent call last):
[  133s]   File "/home/abuild/rpmbuild/BUILD/Flask-Cors-3.0.8/tests/decorator/test_exception_interception.py", line 209, in test_acl_uncaught_exception_500
[  133s]     self.assertFalse(ACL_ORIGIN in resp.headers)
[  133s] AssertionError: True is not false
[  133s] -------------------- >> begin captured logging << --------------------
[  133s] tests.decorator.test_exception_interception: ERROR: Exception on /test_acl_uncaught_exception_500 [GET]
[  133s] Traceback (most recent call last):
[  133s]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 2446, in wsgi_app
[  133s]     response = self.full_dispatch_request()
[  133s]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
[  133s]     rv = self.handle_user_exception(e)
[  133s]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1820, in handle_user_exception
[  133s]     reraise(exc_type, exc_value, tb)
[  133s]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
[  133s]     rv = self.dispatch_request()
[  133s]   File "/usr/lib/python2.7/site-packages/flask/app.py", line 1935, in dispatch_request
[  133s]     return self.view_functions[rule.endpoint](**req.view_args)
[  133s]   File "/home/abuild/rpmbuild/BUILD/Flask-Cors-3.0.8/tests/decorator/test_exception_interception.py", line 30, in test_acl_uncaught_exception_500
[  133s]     raise Exception("This could've been any exception")
[  133s] Exception: This could've been any exception
koobs commented 4 years ago

Confirming on FreeBSD CURRENT (13.x), Python 3.8, Flask 1.1.1, Flask-Cors 3.0.8

======================================================================
FAIL: NoExceptionInterceptionTestCase.test_acl_uncaught_exception_500
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/tmpfs0/usr/home/user/repos/freebsd/ports/www/py-flask-cors/work-py38/Flask-Cors-3.0.8/tests/decorator/test_exception_interception.py", line 209, in test_acl_uncaught_exception_500
    self.assertFalse(ACL_ORIGIN in resp.headers)
AssertionError: True is not false
-------------------- >> begin captured logging << --------------------
tests.decorator.test_exception_interception: ERROR: Exception on /test_acl_uncaught_exception_500 [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/var/tmp/tmpfs0/usr/home/user/repos/freebsd/ports/www/py-flask-cors/work-py38/Flask-Cors-3.0.8/tests/decorator/test_exception_interception.py", line 30, in test_acl_uncaught_exception_500
    raise Exception("This could've been any exception")
Exception: This could've been any exception
GuillaumeSeren commented 4 years ago

Hello, I got the same issue on gentoo, with flask-1.1 python3.7 flask-cors-3.0.8

tests.decorator.test_exception_interception: ERROR: Exception on /test_acl_uncaught_exception_500 [GET]                                                                             
Traceback (most recent call last):                                                                                                                                                  
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app                                                                                                      
    response = self.full_dispatch_request()                                                                                                                                         
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request                                                                                         
    rv = self.handle_user_exception(e)                                                                                                                                              
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception                                                                                         
    reraise(exc_type, exc_value, tb)                                                                                                                                                
  File "/usr/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise                                                                                                     
    raise value                                                                                                                                                                     
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request                                                                                         
    rv = self.dispatch_request()                                                                                                                                                    
  File "/usr/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request                                                                                              
    return self.view_functions[rule.endpoint](**req.view_args)                                                                                                                      
  File "/var/tmp/portage/dev-python/flask-cors-3.0.8/work/Flask-Cors-3.0.8/tests/decorator/test_exception_interception.py", line 30, in test_acl_uncaught_exception_500             
    raise Exception("This could've been any exception")                                                                                                                             
Exception: This could've been any exception  

The problem seems to come from this line: https://github.com/corydolphin/flask-cors/blob/master/tests/decorator/test_exception_interception.py#L209

corydolphin commented 4 years ago

Fixed in release 3.0.9 by skipping the test. Flask improved the error handling behavior, so our exception interception is no longer necessary!