| 1 | # file scalene/scalene_profiler.py:220-223 |
| 2 | # lines [220, 221, 223] |
| 3 | # branches [] |
| 4 | |
| 5 | import threading |
| 6 | from unittest.mock import patch |
| 7 | import pytest |
| 8 | from scalene.scalene_profiler import Scalene |
| 9 | |
| 10 | |
| 11 | # Test function to cover Scalene.get_original_lock |
| 12 | def test_get_original_lock(): |
| 13 | # Setup: Patch the __original_lock attribute to return a mock lock |
| 14 | mock_lock = threading.Lock() |
| 15 | with patch.object(Scalene, "_Scalene__original_lock", return_value=mock_lock): |
| 16 | # Execute the method |
| 17 | result_lock = Scalene.get_original_lock() |
| 18 | # Assert that the result is the mock lock |
| 19 | assert result_lock is mock_lock |
| 20 | |
| 21 | |
| 22 | # Cleanup is handled by the context manager which restores the original state after the block |