| 1 | # file scalene/scalene_profiler.py:402-426 |
| 2 | # lines [402, 403, 417, 422, 423, 424, 426] |
| 3 | # branches [] |
| 4 | |
| 5 | import pytest |
| 6 | from unittest.mock import MagicMock |
| 7 | from scalene.scalene_profiler import Scalene |
| 8 | |
| 9 | |
| 10 | def test_scalene_shim(): |
| 11 | # Create a mock function to be decorated |
| 12 | mock_func = MagicMock() |
| 13 | |
| 14 | # Decorate the mock function using Scalene.shim |
| 15 | decorated_func = Scalene.shim(mock_func) |
| 16 | |
| 17 | # Call the decorated function |
| 18 | result = decorated_func(Scalene) |
| 19 | |
| 20 | # Assert that the original function was called with Scalene as argument |
| 21 | mock_func.assert_called_with(Scalene) |
| 22 | |
| 23 | # Assert that the result of the decorated function is as expected |
| 24 | # Since the mock_func does not have a return_value set, it will return another MagicMock instance |
| 25 | assert isinstance(result, MagicMock) |
| 26 | |
| 27 | # Clean up by deleting the mock function |
| 28 | del mock_func |
| 29 | del decorated_func |
| 30 | |
| 31 | |
| 32 | # Run the test |
| 33 | def test_scalene_shim_coverage(): |
| 34 | test_scalene_shim() |