Debian Codegraph @

tests/test_coverup_30.py

raw symbols SCIP
1 # file scalene/scalene_profiler.py:153-173
2 # lines [153, 154, 157, 158, 159, 160, 161, 162, 164, 165, 166, 168, 170, 171, 172, 173]
3 # branches []
4
5 import os
6 import pytest
7 import sys
8 from scalene.scalene_profiler import Scalene
9 from scalene.scalene_arguments import ScaleneArguments
10 from unittest.mock import patch
11
12
13 @pytest.fixture
14 def cleanup():
15 # Fixture to clean up any state after the test
16 yield
17 # No specific cleanup required for this test
18
19
20 @patch("scalene.scalene_profiler.ScaleneMapFile")
21 def test_scalene_cpu_count(mock_mapfile, cleanup):
22 # Test to cover the branches in Scalene class related to CPU count
23 if hasattr(os, "sched_getaffinity"):
24 expected_cpus = len(os.sched_getaffinity(0))
25 else:
26 expected_cpus = os.cpu_count() if os.cpu_count() else 1
27
28 # Create a ScaleneArguments object with default arguments
29 args = ScaleneArguments()
30 scalene_profiler = Scalene(args)
31 assert scalene_profiler._Scalene__availableCPUs == expected_cpus