Working with PyCharm’s HTTP Requests
When we generated our project, PyCharm created two files. It created main.py
, which we have already examined. It also created a file called test_main.http
. This file is unique to PyCharm. Let’s examine the file shown in Figure 9.7:
Figure 9.7: The HTTP test file generated by PyCharm as part of a FastAPI project
You’ll find the file itself directly next to main.py
(1). We mentioned this as one of the popular conventions for the placement of test files – right next to the file we’re testing. It is called test-main.http
, which lets us know exactly what is being tested. The main.py
file will contain endpoints and test_main.http
will then contain tests for all the endpoints.
This http
test file isn’t code, as we saw in Chapter 6, Seamless Testing, Debugging, and Profiling. This is a specification for HTTP requests. Positions (3) and (4) reveal one test per endpoint in main.py
...