Skip to content

Commit c819e6d

Browse files
committed
added Github delta
1 parent b137da0 commit c819e6d

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/unit/helpers/timestamp_capture/actions/test_Timestamp_Collector__Export.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from osbot_utils.helpers.timestamp_capture.schemas.export.Schema__Export_Summary import Schema__Export_Summary
1111
from osbot_utils.helpers.timestamp_capture.schemas.speedscope.Schema__Speedscope import Schema__Speedscope
1212
from osbot_utils.testing.__ import __, __LESS_THAN__, __BETWEEN__, __SKIP__
13+
from osbot_utils.utils.Env import in_github_action
1314
from osbot_utils.utils.Json import json_to_str
1415

1516

@@ -50,10 +51,14 @@ def test__setup(self): # name with __ s
5051
assert len(self.collector.entries) == 8
5152
assert type(self.export) is Timestamp_Collector__Export
5253

54+
if in_github_action():
55+
delta = 5
56+
else:
57+
delta = 1
5358
with self.export.to_export_summary() as _:
5459
assert type(_) is Schema__Export_Summary
55-
assert _.total_duration_ms < 0.30
56-
assert _.hotspots[0].self_ms < 0.08
60+
assert _.total_duration_ms < 0.30 * delta
61+
assert _.hotspots[0].self_ms < 0.08 * delta
5762

5863
# explicit asserts derived from _.obj() comparison
5964
assert _.name == 'export_test'
@@ -63,48 +68,48 @@ def test__setup(self): # name with __ s
6368

6469
# hotspot 0
6570
assert _.hotspots[0].name == 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.outer'
66-
assert _.hotspots[0].self_ms < 0.08
71+
assert _.hotspots[0].self_ms < 0.08 * delta
6772
assert 35 <= _.hotspots[0].percentage <= 45
6873
assert _.hotspots[0].calls == 1
6974

7075
# hotspot 1
7176
assert _.hotspots[1].name == 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.inner_a'
72-
assert _.hotspots[1].self_ms < 0.05
77+
assert _.hotspots[1].self_ms < 0.05 * delta
7378
assert 20 <= _.hotspots[1].percentage <= 25
7479
assert _.hotspots[1].calls == 1
7580

7681
# hotspot 2
7782
assert _.hotspots[2].name == 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.leaf'
78-
assert _.hotspots[2].self_ms < 0.05
83+
assert _.hotspots[2].self_ms < 0.05 * delta
7984
assert 10 <= _.hotspots[2].percentage <= 15
8085
assert _.hotspots[2].calls == 1
8186

8287
# hotspot 3
8388
assert _.hotspots[3].name == 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.inner_b'
84-
assert _.hotspots[3].self_ms < 0.05
89+
assert _.hotspots[3].self_ms < 0.05 * delta
8590
assert 5 <= _.hotspots[3].percentage <= 15
8691
assert _.hotspots[3].calls == 1
8792

8893
# full object comparison (authoritative)
8994
assert _.obj() == __(name = 'export_test' ,
90-
total_duration_ms= __LESS_THAN__(0.20),
95+
total_duration_ms= __LESS_THAN__(0.20 * delta),
9196
method_count = 4 ,
9297
entry_count = 8 ,
9398
hotspots = [
9499
__(name = 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.outer' ,
95-
self_ms = __LESS_THAN__(0.08),
100+
self_ms = __LESS_THAN__(0.08 * delta),
96101
percentage = __BETWEEN__(35, 45),
97102
calls = 1),
98103
__(name = 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.inner_a',
99-
self_ms = __LESS_THAN__(0.05),
104+
self_ms = __LESS_THAN__(0.05 * delta),
100105
percentage = __BETWEEN__(20, 25),
101106
calls = 1),
102107
__(name = 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.leaf' ,
103-
self_ms = __LESS_THAN__(0.05),
108+
self_ms = __LESS_THAN__(0.05 * delta),
104109
percentage = __BETWEEN__(10, 15),
105110
calls = 1),
106111
__(name = 'test_Timestamp_Collector__Export.create_timestamp_entries.<locals>.inner_b',
107-
self_ms = __LESS_THAN__(0.05),
112+
self_ms = __LESS_THAN__(0.05 * delta),
108113
percentage = __BETWEEN__(5 , 15),
109114
calls = 1)
110115
])

0 commit comments

Comments
 (0)