|
13 | 13 |
|
14 | 14 | from tests.common import TestConsumer |
15 | 15 |
|
16 | | -# Timing constants for wakeable poll pattern tests |
17 | | -# These are lenient ranges to accommodate CI environment variability (especially macOS) |
| 16 | +# Timing constants for wakeable poll/consume pattern tests |
18 | 17 | WAKEABLE_POLL_LONGER_TIMEOUT_MIN = 0.2 # Minimum timeout for longer operations (seconds) |
19 | 18 | WAKEABLE_POLL_LONGER_TIMEOUT_MAX = 2.0 # Maximum timeout for longer operations (seconds) |
20 | 19 | WAKEABLE_POLL_SHORTER_TIMEOUT_MIN = 0.01 # Minimum timeout for shorter operations (seconds) |
@@ -742,7 +741,6 @@ def test_calculate_chunk_timeout_utility_function(): |
742 | 741 | elapsed = time.time() - start |
743 | 742 |
|
744 | 743 | assert msg is None, "Assertion 2 failed: Expected None (timeout)" |
745 | | - # More lenient for CI environments (macOS can be slower) |
746 | 744 | assert WAKEABLE_POLL_LONGER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_LONGER_TIMEOUT_MAX, \ |
747 | 745 | f"Assertion 2 failed: Timeout took {elapsed:.2f}s, expected ~1.0s" |
748 | 746 | consumer2.close() |
@@ -898,7 +896,6 @@ def test_check_signals_between_chunks_utility_function(): |
898 | 896 | elapsed = time.time() - start |
899 | 897 |
|
900 | 898 | assert msg is None, "Assertion 3 failed: Expected None (timeout), no signal should not interrupt" |
901 | | - # More lenient for CI environments (macOS can be slower) |
902 | 899 | assert WAKEABLE_POLL_LONGER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_LONGER_TIMEOUT_MAX, \ |
903 | 900 | f"Assertion 3 failed: No signal timeout took {elapsed:.2f}s, expected ~0.5s" |
904 | 901 | consumer3.close() |
@@ -999,8 +996,7 @@ def test_wakeable_poll_utility_functions_interaction(): |
999 | 996 | elapsed = time.time() - start |
1000 | 997 | # Chunk calculation should continue correctly (200ms each) |
1001 | 998 | # Signal check should happen every chunk |
1002 | | - # Should interrupt within ~0.8s (0.6s signal + 0.2s chunk) |
1003 | | - # More lenient for CI environments (macOS can be slower) |
| 999 | + # Signal sent at 0.6s, should interrupt after that |
1004 | 1000 | msg = (f"Assertion 2 failed: Multiple chunks interaction took " |
1005 | 1001 | f"{elapsed:.2f}s, expected {WAKEABLE_POLL_LONGER_TIMEOUT_MIN}-{WAKEABLE_POLL_LONGER_TIMEOUT_MAX}s") |
1006 | 1002 | assert WAKEABLE_POLL_LONGER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_LONGER_TIMEOUT_MAX, msg |
@@ -1080,8 +1076,7 @@ def test_wakeable_poll_interruptibility_and_messages(): |
1080 | 1076 | assert False, "Assertion 3 failed: Should have raised KeyboardInterrupt" |
1081 | 1077 | except KeyboardInterrupt: |
1082 | 1078 | elapsed = time.time() - start |
1083 | | - # Should interrupt within one chunk period after signal (0.6s + 0.2s = 0.8s max) |
1084 | | - # More lenient for CI environments (macOS can be slower) |
| 1079 | + # Signal sent at 0.6s, should interrupt after that |
1085 | 1080 | msg = (f"Assertion 3 failed: Multiple chunks interrupt took " |
1086 | 1081 | f"{elapsed:.2f}s, expected {WAKEABLE_POLL_LONGER_TIMEOUT_MIN}-{WAKEABLE_POLL_LONGER_TIMEOUT_MAX}s") |
1087 | 1082 | assert WAKEABLE_POLL_LONGER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_LONGER_TIMEOUT_MAX, msg |
@@ -1155,7 +1150,6 @@ def test_wakeable_poll_edge_cases(): |
1155 | 1150 | elapsed = time.time() - start |
1156 | 1151 |
|
1157 | 1152 | assert msg is None, "Assertion 3 failed: Short timeout with no messages should return None" |
1158 | | - # More lenient for CI environments (macOS can be slower) |
1159 | 1153 | assert WAKEABLE_POLL_SHORTER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_SHORTER_TIMEOUT_MAX, \ |
1160 | 1154 | f"Assertion 3 failed: Short timeout took {elapsed:.2f}s, expected ~0.1s" |
1161 | 1155 | consumer3.close() |
@@ -1249,8 +1243,7 @@ def test_wakeable_consume_interruptibility_and_messages(): |
1249 | 1243 | assert False, "Assertion 3 failed: Should have raised KeyboardInterrupt" |
1250 | 1244 | except KeyboardInterrupt: |
1251 | 1245 | elapsed = time.time() - start |
1252 | | - # Should interrupt within one chunk period after signal (0.6s + 0.2s = 0.8s max) |
1253 | | - # More lenient for CI environments (macOS can be slower) |
| 1246 | + # Signal sent at 0.6s, should interrupt after that |
1254 | 1247 | msg = (f"Assertion 3 failed: Multiple chunks interrupt took " |
1255 | 1248 | f"{elapsed:.2f}s, expected {WAKEABLE_POLL_LONGER_TIMEOUT_MIN}-{WAKEABLE_POLL_LONGER_TIMEOUT_MAX}s") |
1256 | 1249 | assert WAKEABLE_POLL_LONGER_TIMEOUT_MIN <= elapsed <= WAKEABLE_POLL_LONGER_TIMEOUT_MAX, msg |
|
0 commit comments