| 1 | # file scalene/scalene_profiler.py:1399-1405 |
| 2 | # lines [1399, 1400, 1405] |
| 3 | # branches [] |
| 4 | |
| 5 | import os |
| 6 | import pytest |
| 7 | from scalene.scalene_profiler import Scalene |
| 8 | |
| 9 | |
| 10 | # Test function to cover the before_fork method |
| 11 | def test_before_fork(monkeypatch): |
| 12 | # Setup: Mock the stop_signal_queues method |
| 13 | monkeypatch.setattr(Scalene, "stop_signal_queues", lambda: None) |
| 14 | |
| 15 | # Test: Call the before_fork method |
| 16 | Scalene.before_fork() |
| 17 | |
| 18 | # Verify: Since we mocked the method, we can't check the actual state, so we just ensure the method was called |
| 19 | # In a real test, we would need to check the actual state or use a more sophisticated mock |
| 20 | # No assertions are needed here as we are just testing that the method can be called without error |
| 21 | |
| 22 | |
| 23 | # Ensure that the test is only run when called by pytest and not during import |
| 24 | if __name__ == "__main__": |
| 25 | pytest.main([__file__]) |