File: test_coverup_89.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 (20 lines) | stat: -rw-r--r-- 723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# file scalene/scalene_profiler.py:220-223
# lines [220, 221, 223]
# branches []

import threading
from unittest.mock import patch
import pytest
from scalene.scalene_profiler import Scalene

# Test function to cover Scalene.get_original_lock
def test_get_original_lock():
    # Setup: Patch the __original_lock attribute to return a mock lock
    mock_lock = threading.Lock()
    with patch.object(Scalene, '_Scalene__original_lock', return_value=mock_lock):
        # Execute the method
        result_lock = Scalene.get_original_lock()
        # Assert that the result is the mock lock
        assert result_lock is mock_lock

# Cleanup is handled by the context manager which restores the original state after the block