Skip to content

Main Entry Point

Module main.py is the main entry point for FauxPy, containing six functions. The function fauxpy_analysis_mode is called when FauxPy starts in Analysis Mode. This function creates an instance of the FauxpyAnalysisModeHandler class, which manages the whole Analysis Mode.

The other five functions in main.py are Pytest hooks executed in Pytest Mode. Module main.py instantiates a FauxpyPytestModeHandler object as a global variable. These hooks call corresponding methods in the object, delegating control of Pytest Mode to class FauxpyPytestModeHandler.

Below are the details of these six functions in main.py.

fauxpy_analysis_mode()

Entry point for FauxPy's Analysis Mode.

This function is called when FauxPy is invoked in Analysis Mode.

Source code in fauxpy/main.py
63
64
65
66
67
68
69
70
def fauxpy_analysis_mode():
    """
    Entry point for FauxPy's Analysis Mode.

    This function is called when FauxPy is invoked in Analysis Mode.
    """
    fauxpy_command_mode_handler = FauxpyAnalysisModeHandler()
    fauxpy_command_mode_handler.main()

pytest_addoption(parser)

This hook is called by Pytest, allowing plugins such as FauxPy to add custom options.

Parameters:

Name Type Description Default
parser

The Pytest parser object.

required
Source code in fauxpy/main.py
 7
 8
 9
10
11
12
13
14
15
def pytest_addoption(parser):
    """
    This hook is called by Pytest, allowing plugins such as FauxPy to
    add custom options.

    Args:
        parser: The Pytest parser object.
    """
    _Fauxpy_pytest_mode_handler.add_option(parser)

pytest_configure(config)

This hook is called by Pytest to allow FauxPy to initialize and configure itself before test execution begins.

Parameters:

Name Type Description Default
config

The Pytest configuration object, which holds configuration options

required
Source code in fauxpy/main.py
18
19
20
21
22
23
24
25
26
27
def pytest_configure(config):
    """
    This hook is called by Pytest to allow FauxPy to initialize and configure
    itself before test execution begins.

    Args:
        config: The Pytest configuration object, which holds configuration options
        and settings for the current test session.
    """
    _Fauxpy_pytest_mode_handler.configure(config)

pytest_runtest_call(item)

This hook is called by Pytest just before running a test (before call.when == "call" in pytest_runtest_makereport).

Parameters:

Name Type Description Default
item

The test item (or node) being executed.

required
Source code in fauxpy/main.py
30
31
32
33
34
35
36
37
38
def pytest_runtest_call(item):
    """
    This hook is called by Pytest just before running a test
    (before `call.when == "call"` in `pytest_runtest_makereport`).

    Args:
        item: The test item (or node) being executed.
    """
    _Fauxpy_pytest_mode_handler.runtest_call(item)

pytest_runtest_makereport(item, call)

This hook is called by Pytest after each test.

Parameters:

Name Type Description Default
item

The test item that was executed.

required
call

The test phase object representing the test's setup, call, or teardown phase.

required
Source code in fauxpy/main.py
41
42
43
44
45
46
47
48
49
def pytest_runtest_makereport(item, call):
    """
    This hook is called by Pytest after each test.

    Args:
        item: The test item that was executed.
        call: The test phase object representing the test's setup, call, or teardown phase.
    """
    _Fauxpy_pytest_mode_handler.runtest_make_report(item, call)

pytest_terminal_summary(terminalreporter, exitstatus)

This hook is called by Pytest after all tests are completed.

Parameters:

Name Type Description Default
terminalreporter

The Pytest terminal reporter object, used to output results.

required
exitstatus

The final exit status of the Pytest session, indicating success or failure.

required
Source code in fauxpy/main.py
52
53
54
55
56
57
58
59
60
def pytest_terminal_summary(terminalreporter, exitstatus):
    """
    This hook is called by Pytest after all tests are completed.

    Args:
        terminalreporter: The Pytest terminal reporter object, used to output results.
        exitstatus: The final exit status of the Pytest session, indicating success or failure.
    """
    _Fauxpy_pytest_mode_handler.terminal_summary(terminalreporter, exitstatus)