File: test_coverup_91.py

package info (click to toggle)
scalene 1.5.51-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 15,528 kB
  • sloc: cpp: 22,930; python: 13,403; javascript: 11,769; ansic: 817; makefile: 196; sh: 45
file content (32 lines) | stat: -rw-r--r-- 960 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# file scalene/scalene_profiler.py:402-426
# lines [402, 403, 417, 422, 423, 424, 426]
# branches []

import pytest
from unittest.mock import MagicMock
from scalene.scalene_profiler import Scalene

def test_scalene_shim():
    # Create a mock function to be decorated
    mock_func = MagicMock()

    # Decorate the mock function using Scalene.shim
    decorated_func = Scalene.shim(mock_func)

    # Call the decorated function
    result = decorated_func(Scalene)

    # Assert that the original function was called with Scalene as argument
    mock_func.assert_called_with(Scalene)

    # Assert that the result of the decorated function is as expected
    # Since the mock_func does not have a return_value set, it will return another MagicMock instance
    assert isinstance(result, MagicMock)

    # Clean up by deleting the mock function
    del mock_func
    del decorated_func

# Run the test
def test_scalene_shim_coverage():
    test_scalene_shim()