tests/conftest.py
def patch_constants(
    monkeypatch, test_home_path
):  # pylint: disable=redefined-outer-name
    """
    For pytest, override the default constants used in sonar

    Args:
        monkeypatch (monkeypatch): Defined in pytest for monkeypatching code
        test_home_path (str): Path to the new home directory for sonar
    """

    @init_constants
    class MockConstants(Constants):
        """
        New mock Constants class that inherits all the constants from the base
        class but overrides the base path to our temporary home path
        """

        SONAR_BASE_PATH = Path(test_home_path)

    # each of these files imports their own version of the Constants so we need
    # to override all of them. Within the test directory, we use the full import
    # path to import constants to avoid this requirement.
    monkeypatch.setattr("sonar.api.Constants", MockConstants)
    monkeypatch.setattr("sonar.database.Constants", MockConstants)
    monkeypatch.setattr("sonar.core.include.Constants", MockConstants)

    For pytest, override the default constants used in sonar

    Args:
        monkeypatch (monkeypatch): Defined in pytest for monkeypatching code
        test_home_path (str): Path to the new home directory for sonar
    
For pytest, override the default constants used in sonar
For pytest override the default constants used in sonar
def patch_constants(
    monkeypatch, test_home_path
):  
    @init_constants
    class MockConstants(Constants):
        SONAR_BASE_PATH = Path(test_home_path)
    monkeypatch.setattr("sonar.api.Constants", MockConstants)
    monkeypatch.setattr("sonar.database.Constants", MockConstants)
    monkeypatch.setattr("sonar.core.include.Constants", MockConstants)
def patch_constants ( monkeypatch , test_home_path ) : @ init_constants class MockConstants ( Constants ) : """
        New mock Constants class that inherits all the constants from the base
        class but overrides the base path to our temporary home path
        """ SONAR_BASE_PATH = Path ( test_home_path ) monkeypatch . setattr ( "sonar.api.Constants" , MockConstants ) monkeypatch . setattr ( "sonar.database.Constants" , MockConstants ) monkeypatch . setattr ( "sonar.core.include.Constants" , MockConstants )
For pytest, override the default constants used in sonar
For pytest override the default constants used in sonar
# pylint: disable=redefined-outer-name """
    For pytest, override the default constants used in sonar

    Args:
        monkeypatch (monkeypatch): Defined in pytest for monkeypatching code
        test_home_path (str): Path to the new home directory for sonar
    """ """
        New mock Constants class that inherits all the constants from the base
        class but overrides the base path to our temporary home path
        """ # each of these files imports their own version of the Constants so we need # to override all of them. Within the test directory, we use the full import # path to import constants to avoid this requirement.
monkeypatch
Defined in pytest for monkeypatching code
Defined in pytest for monkeypatching code
test_home_path
Path to the new home directory for sonar
Path to the new home directory for sonar