Home / File/ conftest.py — flask Source File

conftest.py — flask Source File

Architecture documentation for conftest.py, a python file in the flask codebase. 6 imports, 0 dependents.

File python ApplicationCore ExtensionRegistry 6 imports 12 functions

Entity Profile

Dependency Diagram

graph LR
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6["conftest.py"]
  bdc6911d_da67_3a1f_90cb_90f5e9f0603e["os"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> bdc6911d_da67_3a1f_90cb_90f5e9f0603e
  8e9cc1cb_fabe_237c_ff24_85400e094882["sys"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> 8e9cc1cb_fabe_237c_ff24_85400e094882
  da94d511_b8b8_a450_f67f_fc28ea9b648a["pytest"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> da94d511_b8b8_a450_f67f_fc28ea9b648a
  028619fc_197c_3b1c_8cd7_23bcf1a642d6["_pytest"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> 028619fc_197c_3b1c_8cd7_23bcf1a642d6
  8c762fc5_c0b6_0d4d_3889_896d80fbf225["flask"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> 8c762fc5_c0b6_0d4d_3889_896d80fbf225
  3e36f42e_6b7c_ad20_fe7e_3ce2e69941e4["flask.globals"]
  91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 --> 3e36f42e_6b7c_ad20_fe7e_3ce2e69941e4
  style 91da8911_f5f3_2fff_0b5f_8e0f6b24cbf6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import os
import sys

import pytest
from _pytest import monkeypatch

from flask import Flask
from flask.globals import app_ctx as _app_ctx


@pytest.fixture(scope="session", autouse=True)
def _standard_os_environ():
    """Set up ``os.environ`` at the start of the test session to have
    standard values. Returns a list of operations that is used by
    :func:`._reset_os_environ` after each test.
    """
    mp = monkeypatch.MonkeyPatch()
    out = (
        (os.environ, "FLASK_ENV_FILE", monkeypatch.notset),
        (os.environ, "FLASK_APP", monkeypatch.notset),
        (os.environ, "FLASK_DEBUG", monkeypatch.notset),
        (os.environ, "FLASK_RUN_FROM_CLI", monkeypatch.notset),
        (os.environ, "WERKZEUG_RUN_MAIN", monkeypatch.notset),
    )

    for _, key, value in out:
        if value is monkeypatch.notset:
            mp.delenv(key, False)
        else:
            mp.setenv(key, value)

    yield out
    mp.undo()


@pytest.fixture(autouse=True)
def _reset_os_environ(monkeypatch, _standard_os_environ):
    """Reset ``os.environ`` to the standard environ after each test,
    in case a test changed something without cleaning up.
    """
    monkeypatch._setitem.extend(_standard_os_environ)


@pytest.fixture
def app():
    app = Flask("flask_test", root_path=os.path.dirname(__file__))
    app.config.update(
        TESTING=True,
        SECRET_KEY="test key",
    )
    return app


@pytest.fixture
def app_ctx(app):
    with app.app_context() as ctx:
        yield ctx


@pytest.fixture
// ... (70 more lines)

Subdomains

Dependencies

  • _pytest
  • flask
  • flask.globals
  • os
  • pytest
  • sys

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 12 function(s): _reset_os_environ, _standard_os_environ, app, app_ctx, client, leak_detector, modules_tmp_path, modules_tmp_path_prefix, purge_module, req_ctx, and 2 more.
What does conftest.py depend on?
conftest.py imports 6 module(s): _pytest, flask, flask.globals, os, pytest, sys.
Where is conftest.py in the architecture?
conftest.py is located at tests/conftest.py (domain: ApplicationCore, subdomain: ExtensionRegistry, directory: tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free