# file scalene/scalene_profiler.py:131-138 # lines [138] # branches [] import pytest from unittest.mock import patch # Assuming the Scalene.profile method is implemented elsewhere in the scalene_profiler.py # and that it has some observable side effect or return value we can test. # Mock the Scalene.profile method to simulate the behavior we want to test. def mock_profile(func): # Simulate some behavior of the profile method that we can assert on. func.has_been_profiled = True return func # Apply the patch to the Scalene.profile method @pytest.fixture def mock_scalene(monkeypatch): monkeypatch.setattr("scalene.scalene_profiler.Scalene.profile", mock_profile) def test_scalene_redirect_profile(mock_scalene): # Assuming scalene_redirect_profile is a function in the scalene_profiler module from scalene.scalene_profiler import scalene_redirect_profile # Define a dummy function to be decorated def dummy_function(): pass # Decorate the dummy function using the scalene_redirect_profile decorated_function = scalene_redirect_profile(dummy_function) # Assert that the function has been 'profiled' by checking the side effect assert hasattr(decorated_function, "has_been_profiled") assert decorated_function.has_been_profiled is True