I have a Flask server that has server.py
set up in the following way
server.py
app = Flask(__name__)
app.register_blueprint(mybp)
if __name__ == '__main__':
app.config.foo = "bar"
mybp.py
@mybp.route('/', methods=['POST'])
def root():
return app.config.foo
test.py
@pytest.fixture
def client():
server.app.config['TESTING'] = True
client = server.app.test_client()
client
yield client
def testbp(client):
client.post('/mybp')
When I run the test, I get the following error
E AttributeError: 'Config' object has no attribute 'foo'
because the configuration hasn't been initialized when running the test.