File: test_coverup_92.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 (29 lines) | stat: -rw-r--r-- 1,052 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
# file scalene/scalene_profiler.py:118-121
# lines [118, 119, 120, 121]
# branches []

import sys
from unittest.mock import patch
import pytest

# Assuming the correct import based on the error message
from scalene import scalene_profiler

def test_require_python():
    # Save the original version info
    original_version_info = sys.version_info

    # Test with a version that should pass
    with patch.object(sys, 'version_info', (3, 8)):
        scalene_profiler.require_python((3, 6))  # Should not raise an assertion error

    # Test with a version that should fail and raise an assertion error
    with patch.object(sys, 'version_info', (3, 5)), pytest.raises(AssertionError):
        scalene_profiler.require_python((3, 6))

    # Clean up by restoring the original version info
    sys.version_info = original_version_info

# Ensure that the test does not affect other tests by checking the version after the test
def test_version_info_unchanged():
    assert sys.version_info >= (3, 6), "sys.version_info should be unchanged after tests"