:py:mod:`pytest_flakefighters.flakefighters.deflaker` ===================================================== .. py:module:: pytest_flakefighters.flakefighters.deflaker .. autoapi-nested-parse:: This module implements the DeFlaker FlakeFighter. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pytest_flakefighters.flakefighters.deflaker.DeFlaker .. py:class:: DeFlaker(run_live: bool, root: str = '.', source_commit: str = None, target_commit: str = None) Bases: :py:obj:`pytest_flakefighters.flakefighters.abstract_flakefighter.FlakeFighter` A python equivalent of the DeFlaker algorithm from `Bell et al. (2019) `_. Given the subtle differences between JUnit and pytest, this is not intended to be an exact port, but it follows the same general methodology of checking whether covered code has been changed between commits. :ivar run_live: Run detection "live" after each test. Otherwise run as a postprocessing step after the test suite. :ivar root: The root directory of the Git repository. :ivar source_commit: The source (older) commit hash. Defaults to HEAD^ (the previous commit to target). :ivar target_commit: The target (newer) commit hash. Defaults to HEAD (the most recent commit). .. py:method:: from_config(config: dict) :classmethod: Factory method to create a new instance from a pytest configuration. .. py:method:: params() Convert the key parameters into a dictionary so that the object can be replicated. :return A dictionary of the parameters used to create the object. .. py:method:: line_modified_by_target_commit(file_path: str, line_no: int) -> bool Returns true if the given line in the file has been modified by the present commit. :param file_path: The file to check. :param line_no: The line number to check. .. py:method:: _flaky_execution(execution) Classify an execution as flaky or not. :return: Boolean True of the test is classed as flaky and False otherwise. .. py:method:: flaky_test_live(execution: pytest_flakefighters.database_management.TestExecution) Classify a failing test as flaky if it does not cover any code which has been changed between the source and target commits. :param execution: The test execution to classify. .. py:method:: flaky_tests_post(run: pytest_flakefighters.database_management.Run) -> list[bool | None] Classify failing tests as flaky if any of their executions are flaky. :param run: Run object representing the pytest run, with tests accessible through run.tests.