GoogleCloudPlatform / GoogleCloudPlatform/appengine-python-standard
os.environ not passed through Flask test_client() after Flask app been wrapped by wrap_wsgi_app()
- Dominant language
- Python
- Stars
- 86
- Forks
- 61
- PR merge metrics
- No merged PRs in 30d
Description
## Expected Behavior
```
ID1 before test_client(): 123
ID2 before test_client(): 456
APPLICATION_ID after test_client(): testbed-test
ID1 after test_client(): 123
ID2 after test_client(): 456
APPLICATION_ID after test_client(): testbed-test
```
## Actual Behavior
```
ID1 before test_client(): 123
ID2 before test_client(): 456
APPLICATION_ID after test_client(): testbed-test
ID1 after test_client(): 123
ID2 after test_client():
APPLICATION_ID after test_client():
```
## Steps to Reproduce the Problem
1. Run the following code with Python 3
```
from flask import Flask
from google.appengine.api import wrap_wsgi_app
from google.appengine.ext import testbed
import os
os.environ['ID1'] = "123"
app = Flask(__name__)
app.wsgi_app = wrap_wsgi_app(app.wsgi_app)
os.environ['ID2'] = "456"
@app.route('/')
def hello():
print("ID1 after test_client(): %s" % os.environ.get("ID1", ""))
print("ID2 after test_client(): %s" % os.environ.get("ID2", ""))
print("APPLICATION_ID after test_client(): %s" % os.environ.get("APPLICATION_ID", ""))
return "OK"
t = testbed.Testbed()
t.activate()
t.setup_env()
print("ID1 before test_client(): %s" % os.environ.get("ID1", ""))
print("ID2 before test_client(): %s" % os.environ.get("ID2", ""))
print("APPLICATION_ID after test_client(): %s" % os.environ.get("APPLICATION_ID", ""))
app.test_client().get('/')
```
## Specifications
- Version: appengine-python-standard 1.0.0
- Platform: Python 3.9
Contributor guide
Assessment
This issue has not been assessed yet.