Contribute Media
A thank you to everyone who makes this possible: Read More

Demystifying Flask's Application and Request Contexts with pytest

Description

The application and request contexts are key parts of any Flask application, as they control which variables are and are not globally accessible. Understanding how each context works is important when developing Flask applications, and yet they are often misunderstood. This talk dives into how the application and request contexts work when handling a request. The concept of proxies is discussed for providing thread-local access to the application and request contexts. To really illustrate how the application context works, pytest will be utilized to show how the application context works outside of a request. This example shows a common error ('Working outside of application context') during testing and how it should be solved by pushing to the application context stack.

Details

Improve this page