conftest.py — flask Source File
Architecture documentation for conftest.py, a python file in the flask codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 2f7e4e80_be3d_7829_3628_0cb296db6764["conftest.py"] bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"] 2f7e4e80_be3d_7829_3628_0cb296db6764 --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e a3c4d41f_ecdd_2614_7390_cb72ac385b02["tempfile"] 2f7e4e80_be3d_7829_3628_0cb296db6764 --> a3c4d41f_ecdd_2614_7390_cb72ac385b02 da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"] 2f7e4e80_be3d_7829_3628_0cb296db6764 --> da94d511_b8b8_a450_f67f_fc28ea9b648a 46343131_a7b2_1f08_c964_dac29fad8199["flaskr"] 2f7e4e80_be3d_7829_3628_0cb296db6764 --> 46343131_a7b2_1f08_c964_dac29fad8199 2908b311_ad9c_2dc9_c8a1_842d263dcf86["flaskr.db"] 2f7e4e80_be3d_7829_3628_0cb296db6764 --> 2908b311_ad9c_2dc9_c8a1_842d263dcf86 style 2f7e4e80_be3d_7829_3628_0cb296db6764 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import os
import tempfile
import pytest
from flaskr import create_app
from flaskr.db import get_db
from flaskr.db import init_db
# read in SQL for populating test data
with open(os.path.join(os.path.dirname(__file__), "data.sql"), "rb") as f:
_data_sql = f.read().decode("utf8")
@pytest.fixture
def app():
"""Create and configure a new app instance for each test."""
# create a temporary file to isolate the database for each test
db_fd, db_path = tempfile.mkstemp()
# create the app with common test config
app = create_app({"TESTING": True, "DATABASE": db_path})
# create the database and load test data
with app.app_context():
init_db()
get_db().executescript(_data_sql)
yield app
# close and remove the temporary database
os.close(db_fd)
os.unlink(db_path)
@pytest.fixture
def client(app):
"""A test client for the app."""
return app.test_client()
@pytest.fixture
def runner(app):
"""A test runner for the app's Click commands."""
return app.test_cli_runner()
class AuthActions:
def __init__(self, client):
self._client = client
def login(self, username="test", password="test"):
return self._client.post(
"/auth/login", data={"username": username, "password": password}
)
def logout(self):
return self._client.get("/auth/logout")
@pytest.fixture
def auth(client):
return AuthActions(client)
Domain
Subdomains
Functions
Classes
Dependencies
- flaskr
- flaskr.db
- os
- pytest
- tempfile
Source
Frequently Asked Questions
What does conftest.py do?
conftest.py is a source file in the flask codebase, written in python. It belongs to the ApplicationCore domain, ExtensionRegistry subdomain.
What functions are defined in conftest.py?
conftest.py defines 5 function(s): _data_sql, app, auth, client, runner.
What does conftest.py depend on?
conftest.py imports 5 module(s): flaskr, flaskr.db, os, pytest, tempfile.
Where is conftest.py in the architecture?
conftest.py is located at examples/tutorial/tests/conftest.py (domain: ApplicationCore, subdomain: ExtensionRegistry, directory: examples/tutorial/tests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free