mirror of https://github.com/pallets/flask.git
				
				
				
			Merge remote-tracking branch 'origin/1.1.x'
This commit is contained in:
		
						commit
						a83d6d2528
					
				| 
						 | 
					@ -170,8 +170,8 @@ will not fail.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
During testing, it can be useful to defer popping the contexts after the
 | 
					During testing, it can be useful to defer popping the contexts after the
 | 
				
			||||||
request ends, so that their data can be accessed in the test function.
 | 
					request ends, so that their data can be accessed in the test function.
 | 
				
			||||||
Using the :meth:`~Flask.test_client` as a ``with`` block to preserve the
 | 
					Use the :meth:`~Flask.test_client` as a ``with`` block to preserve the
 | 
				
			||||||
contexts until the with block exits.
 | 
					contexts until the ``with`` block exits.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.. code-block:: python
 | 
					.. code-block:: python
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11,6 +11,7 @@
 | 
				
			||||||
import datetime
 | 
					import datetime
 | 
				
			||||||
import io
 | 
					import io
 | 
				
			||||||
import os
 | 
					import os
 | 
				
			||||||
 | 
					import sys
 | 
				
			||||||
import uuid
 | 
					import uuid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import pytest
 | 
					import pytest
 | 
				
			||||||
| 
						 | 
					@ -780,12 +781,17 @@ class TestSendfile(object):
 | 
				
			||||||
        assert rv.data.strip() == b"Hello Subdomain"
 | 
					        assert rv.data.strip() == b"Hello Subdomain"
 | 
				
			||||||
        rv.close()
 | 
					        rv.close()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_send_from_directory_bad_request(self, app, req_ctx):
 | 
					    def test_send_from_directory_null_character(self, app, req_ctx):
 | 
				
			||||||
        app.root_path = os.path.join(
 | 
					        app.root_path = os.path.join(
 | 
				
			||||||
            os.path.dirname(__file__), "test_apps", "subdomaintestmodule"
 | 
					            os.path.dirname(__file__), "test_apps", "subdomaintestmodule"
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        with pytest.raises(BadRequest):
 | 
					        if sys.version_info >= (3, 8):
 | 
				
			||||||
 | 
					            exception = NotFound
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            exception = BadRequest
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        with pytest.raises(exception):
 | 
				
			||||||
            flask.send_from_directory("static", "bad\x00")
 | 
					            flask.send_from_directory("static", "bad\x00")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue