pytest_flakefighters.database_management
This module manages all interaction with the test run database.
Module Contents
Classes
Declarative base class for data objects. |
|
Class to store attributes of a flakefighters run. |
|
Store relevant information about the active flakefighters. |
|
Class to store attributes of a test case. |
|
Class to store attributes of a test outcome. |
|
Class to store information about the exceptions that cause tests to fail. |
|
Class to store attributes of entries in the stack trace. |
|
Class to store flakefighter results. |
|
Class to handle database setup and interaction. |
- class pytest_flakefighters.database_management.Base
Bases:
sqlalchemy.orm.DeclarativeBaseDeclarative base class for data objects.
- Variables:
id – Unique autoincrementing ID for the object.
- id: sqlalchemy.orm.Mapped[int]
- __test__ = False
- __tablename__()
- class pytest_flakefighters.database_management.Run
Bases:
BaseClass to store attributes of a flakefighters run. :ivar start_time: The time the test run was begun. :ivar created_at: The time the entry was added to the database. This is not necessarily equivalent to start_time if the test suite took a long time to run or if the entry was migrated from a separate database. :ivar root: The root directory of the project. :ivar tests: The test suite. :ivar active_flakefighters: The flakefighters that are active on the run.
- start_time
- created_at
- root: sqlalchemy.orm.Mapped[str]
- tests
- active_flakefighters
- class pytest_flakefighters.database_management.ActiveFlakeFighter
Bases:
BaseStore relevant information about the active flakefighters.
- Variables:
run_id – Foreign key of the related run.
name – Class name of the flakefighter.
params – The parameterss of the flakefighter.
- run_id: sqlalchemy.orm.Mapped[int]
- name: sqlalchemy.orm.Mapped[str]
- params: sqlalchemy.orm.Mapped[dict]
- class pytest_flakefighters.database_management.Test
Bases:
BaseClass to store attributes of a test case.
- Variables:
run_id – Foreign key of the related run.
fspath – File system path of the file containing the test definition.
line_no – Line number of the test definition.
name – Name of the test case.
skipped – Boolean true if the test was skipped, else false.
executions – List of execution attempts.
flakefighter_results – List of test-level flakefighter results.
Note
Execution-level flakefighter results will be stored inside the individual TestExecution objects
- property flaky: bool
Return whether a test (or any of its executions) has been marked as flaky by any flakefighter.
- run_id: sqlalchemy.orm.Mapped[int]
- fspath: sqlalchemy.orm.Mapped[str]
- line_no: sqlalchemy.orm.Mapped[int]
- name: sqlalchemy.orm.Mapped[str]
- skipped: sqlalchemy.orm.Mapped[bool]
- executions
- flakefighter_results
- class pytest_flakefighters.database_management.TestExecution
Bases:
BaseClass to store attributes of a test outcome.
- Variables:
test_id – Foreign key of the related test.
outcome – Outcome of the test. One of “passed”, “failed”, or “skipped”.
stdout – The captured stdout string.
stedrr – The captured stderr string.
start_time – The start time of the test.
end_time – The end time of the test.
coverage – The line coverage of the test.
flakefighter_results – The execution-level flakefighter results.
exception – The exception associated with the test if one was thrown.
- property flaky: bool
Return whether a test (or any of its executions) has been marked as flaky by any flakefighter.
- __tablename__ = 'test_execution'
- test_id: sqlalchemy.orm.Mapped[int]
- outcome: sqlalchemy.orm.Mapped[str]
- stdout: sqlalchemy.orm.Mapped[str]
- stderr: sqlalchemy.orm.Mapped[str]
- report: sqlalchemy.orm.Mapped[str]
- start_time: sqlalchemy.orm.Mapped[datetime.datetime]
- end_time: sqlalchemy.orm.Mapped[datetime.datetime]
- coverage: sqlalchemy.orm.Mapped[dict]
- flakefighter_results
- exception
- class pytest_flakefighters.database_management.TestException
Bases:
BaseClass to store information about the exceptions that cause tests to fail.
- Variables:
execution_id – Foreign key of the related execution.
name – Name of the exception.
- Traceback:
The full stack of traceback entries.
- __tablename__ = 'test_exception'
- execution_id: sqlalchemy.orm.Mapped[int]
- name: sqlalchemy.orm.Mapped[str]
- traceback
- class pytest_flakefighters.database_management.TracebackEntry
Bases:
BaseClass to store attributes of entries in the stack trace.
- Variables:
exception_id – Foreign key of the related exception.
path – Filepath of the source file.
lineno – Line number of the executed statement.
colno – Column number of the executed statement.
statement – The executed statement.
source – The surrounding source code.
- exception_id: sqlalchemy.orm.Mapped[int]
- path: sqlalchemy.orm.Mapped[str]
- lineno: sqlalchemy.orm.Mapped[int]
- colno: sqlalchemy.orm.Mapped[int]
- statement: sqlalchemy.orm.Mapped[str]
- source: sqlalchemy.orm.Mapped[str]
- class pytest_flakefighters.database_management.FlakefighterResult
Bases:
BaseClass to store flakefighter results.
- Variables:
test_execution_id – Foreign key of the related test execution. Should not be set if test_id is present.
test_id – Foreign key of the related test. Should not be set if test_execution_id is present.
name – Name of the flakefighter.
flaky – Boolean true if the test (execution) was classified as flaky.
- property classification
Return the classification as a string. “flaky” if the test was classified as flaky, else “genuine”.
- __tablename__ = 'flakefighter_result'
- test_execution_id: sqlalchemy.orm.Mapped[int]
- test_id: sqlalchemy.orm.Mapped[int]
- name: sqlalchemy.orm.Mapped[str]
- flaky: sqlalchemy.orm.Mapped[bool]
- __table_args__ = ()
- class pytest_flakefighters.database_management.Database(url: str, load_max_runs: int = None, store_max_runs: int = None, time_immemorial: datetime.timedelta | str = None)
Class to handle database setup and interaction.
- Variables:
engine – The database engine.
store_max_runs – The maximum number of previous runs that should be stored. If the database exceeds this size, older runs will be pruned to make space for newer ones.
time_immemorial – Time before which runs should not be considered. Runs before this date will be pruned when saving new runs.
previous_runs – List of previous flakefighter runs with most recent first.
- load_runs(limit: int = None)
Load runs from the database.
- Parameters:
limit – The maximum number of runs to return (these will be most recent runs).