Debian Codegraph @

tests/test_coverup_85.py

raw symbols SCIP
1 # file scalene/scalene_json.py:70-90
2 # lines [81, 83, 85, 87, 88, 90]
3 # branches ['73->81', '85->87', '85->90']
4
5 import pytest
6 from scalene.scalene_json import ScaleneJSON
7 from typing import List, Any
8 import random
9
10
11 class MockScaleneJSON(ScaleneJSON):
12 def __init__(self, max_sparkline_samples):
13 self.max_sparkline_samples = max_sparkline_samples
14
15
16 @pytest.fixture
17 def mock_scalene_json():
18 return MockScaleneJSON(max_sparkline_samples=10)
19
20
21 def test_compress_samples_exceeds_max_samples(mock_scalene_json):
22 # Generate a list of samples that exceeds the max_sparkline_samples
23 # Each sample needs to be a tuple with two elements (x, y) to be subscriptable, as expected by rdp
24 samples = [
25 (i, random.random()) for i in range(1000)
26 ] # 1000 is arbitrary, but should be > max_sparkline_samples * 3
27 compressed_samples = mock_scalene_json.compress_samples(samples, max_footprint=0)
28 assert len(compressed_samples) <= mock_scalene_json.max_sparkline_samples
29 # Clean up
30 del mock_scalene_json