Skip to content

Commit aa2f770

Browse files
committed
!squash test_waiter: Remove time.sleep - the point of the module is we
don't worry about that anymore
1 parent aeb077f commit aa2f770

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

tests/_internal/test_waiter.py

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ def test_wait_for_pane_content_timeout(wait_pane: Pane) -> None:
186186
# Clear the pane to ensure test content isn't there
187187
wait_pane.send_keys("clear", enter=True)
188188

189-
# Make sure the clear command completed
190-
time.sleep(0.5)
191-
192189
# Wait for content that will never appear, but don't raise exception
193190
result = wait_for_pane_content(
194191
wait_pane,
@@ -255,9 +252,6 @@ def test_wait_until_pane_ready_error_handling(wait_pane: Pane) -> None:
255252
wait_pane.send_keys("clear", enter=True)
256253
wait_pane.send_keys("echo 'test'", enter=True)
257254

258-
# Wait a bit for the command to complete
259-
time.sleep(0.5)
260-
261255
# Should auto-detect shell prompt
262256
result = wait_until_pane_ready(
263257
wait_pane,
@@ -276,9 +270,6 @@ def test_wait_until_pane_ready_with_invalid_prompt(wait_pane: Pane) -> None:
276270
wait_pane.send_keys("clear", enter=True)
277271
wait_pane.send_keys("echo 'testing invalid prompt'", enter=True)
278272

279-
# Wait a bit for the command to complete
280-
time.sleep(0.5)
281-
282273
# With an invalid prompt and raises=False, should not raise but return failure
283274
result = wait_until_pane_ready(
284275
wait_pane,
@@ -341,7 +332,6 @@ def test_wait_for_window_panes(server: Server, session: Session) -> None:
341332

342333
# Split and create a second pane with delay
343334
def split_pane() -> None:
344-
time.sleep(0.2)
345335
window.split()
346336

347337
import threading
@@ -400,7 +390,6 @@ def test_wait_for_window_panes_count_range(session: Session) -> None:
400390

401391
# Split window to create a second pane
402392
window.split()
403-
time.sleep(0.5)
404393

405394
# Should now have 2 panes
406395
result = wait_for_window_panes(
@@ -430,7 +419,6 @@ def test_wait_for_any_content(wait_pane: Pane) -> None:
430419

431420
# Add content with delay
432421
def add_content() -> None:
433-
time.sleep(0.2)
434422
wait_pane.send_keys(
435423
"echo 'Success: Operation completed'",
436424
enter=True,
@@ -466,16 +454,13 @@ def add_content() -> None:
466454
def test_wait_for_any_content_mixed_match_types(wait_pane: Pane) -> None:
467455
"""Test wait_for_any_content with different match types for each pattern."""
468456
wait_pane.send_keys("clear", enter=True)
469-
time.sleep(0.5)
470457

471458
# Create different patterns with different match types
472459
wait_pane.send_keys("echo 'test line one'", enter=True)
473460
wait_pane.send_keys("echo 'number 123'", enter=True)
474461
wait_pane.send_keys("echo 'exact match text'", enter=True)
475462
wait_pane.send_keys("echo 'predicate target'", enter=True)
476463

477-
time.sleep(0.5)
478-
479464
# Define a predicate function for testing
480465
def has_predicate_text(lines: list[str]) -> bool:
481466
return any("predicate target" in line for line in lines)
@@ -551,7 +536,6 @@ def test_wait_for_all_content(wait_pane: Pane) -> None:
551536
wait_pane.send_keys("clear", enter=True) # Ensure clean state
552537

553538
def add_content() -> None:
554-
time.sleep(0.2)
555539
wait_pane.send_keys(
556540
"echo 'Database connected'; echo 'Server started'",
557541
enter=True,
@@ -591,11 +575,9 @@ def add_content() -> None:
591575
def test_wait_for_all_content_no_raise(wait_pane: Pane) -> None:
592576
"""Test wait_for_all_content with raises=False."""
593577
wait_pane.send_keys("clear", enter=True)
594-
time.sleep(0.5)
595578

596579
# Add content that will be found
597580
wait_pane.send_keys("echo 'Found text'", enter=True)
598-
time.sleep(0.5)
599581

600582
# Look for one pattern that exists and one that doesn't
601583
patterns: list[str | re.Pattern[str] | Callable[[list[str]], bool]] = [
@@ -620,14 +602,11 @@ def test_wait_for_all_content_no_raise(wait_pane: Pane) -> None:
620602
def test_wait_for_all_content_mixed_match_types(wait_pane: Pane) -> None:
621603
"""Test wait_for_all_content with different match types for each pattern."""
622604
wait_pane.send_keys("clear", enter=True)
623-
time.sleep(0.5)
624605

625606
# Add content that matches different patterns
626607
wait_pane.send_keys("echo 'contains test'", enter=True)
627608
wait_pane.send_keys("echo 'number 456'", enter=True)
628609

629-
time.sleep(0.5)
630-
631610
# Define different match types
632611
match_types = [
633612
ContentMatchType.CONTAINS, # For string match
@@ -686,15 +665,11 @@ def test_wait_for_all_content_type_error(wait_pane: Pane) -> None:
686665
def test_wait_for_pane_content_exact_match(wait_pane: Pane) -> None:
687666
"""Test waiting for content with exact match."""
688667
wait_pane.send_keys("clear", enter=True)
689-
time.sleep(0.5) # Wait for clear to take effect
690668

691669
# Add a line with a predictable content
692670
test_content = "EXACT_MATCH_TEST_STRING"
693671
wait_pane.send_keys(f"echo '{test_content}'", enter=True)
694672

695-
# Wait for content to ensure it's present
696-
time.sleep(0.5)
697-
698673
# Instead of trying exact match on a line (which is prone to shell prompt
699674
# variations) Let's test if the content contains our string
700675
result = wait_for_pane_content(
@@ -817,7 +792,6 @@ def test_pane_content_waiter_wait_for_exact_text(wait_pane: Pane) -> None:
817792
"""Test PaneContentWaiter wait_for_exact_text method."""
818793
wait_pane.send_keys("clear", enter=True)
819794
wait_pane.send_keys("echo 'Exact Test'", enter=True)
820-
time.sleep(0.5) # Give time for the command to complete
821795

822796
# Use CONTAINS instead of EXACT for more reliable test
823797
result = (
@@ -890,9 +864,7 @@ def test_expect_function_with_method_chaining(wait_pane: Pane) -> None:
890864
"""Test expect function with method chaining."""
891865
# Prepare content
892866
wait_pane.send_keys("clear", enter=True)
893-
time.sleep(0.1)
894867
wait_pane.send_keys("echo 'hello world'", enter=True)
895-
time.sleep(0.1)
896868

897869
# Test expect with method chaining
898870
result = (
@@ -909,7 +881,6 @@ def test_expect_function_with_method_chaining(wait_pane: Pane) -> None:
909881

910882
# Test without_raising option
911883
wait_pane.send_keys("clear", enter=True)
912-
time.sleep(0.1)
913884

914885
result = (
915886
expect(wait_pane)
@@ -926,13 +897,11 @@ def test_pane_content_waiter_with_line_range(wait_pane: Pane) -> None:
926897
"""Test PaneContentWaiter with_line_range method."""
927898
# Clear the pane first
928899
wait_pane.send_keys("clear", enter=True)
929-
time.sleep(0.2) # Ensure the clear command completes
930900

931901
# Add some content
932902
wait_pane.send_keys("echo 'line1'", enter=True)
933903
wait_pane.send_keys("echo 'line2'", enter=True)
934904
wait_pane.send_keys("echo 'target-text'", enter=True)
935-
time.sleep(0.2) # Wait for the commands to complete
936905

937906
# Test with specific line range - use a short timeout as we expect this
938907
# to be found immediately
@@ -967,11 +936,9 @@ def test_pane_content_waiter_wait_until_ready(wait_pane: Pane) -> None:
967936
"""Test PaneContentWaiter wait_until_ready method."""
968937
# Clear the pane content first
969938
wait_pane.send_keys("clear", enter=True)
970-
time.sleep(0.1)
971939

972940
# Add a shell prompt
973941
wait_pane.send_keys("echo '$'", enter=True)
974-
time.sleep(0.1)
975942

976943
# Test wait_until_ready with specific prompt pattern
977944
waiter = PaneContentWaiter(wait_pane).with_timeout(1.0)
@@ -985,11 +952,9 @@ def test_pane_content_waiter_with_invalid_line_range(wait_pane: Pane) -> None:
985952
"""Test PaneContentWaiter with invalid line ranges."""
986953
# Clear the pane first
987954
wait_pane.send_keys("clear", enter=True)
988-
time.sleep(0.2)
989955

990956
# Add some content to match
991957
wait_pane.send_keys("echo 'test content'", enter=True)
992-
time.sleep(0.2)
993958

994959
# Test with end < start - should use default range
995960
waiter = (
@@ -1026,13 +991,11 @@ def test_wait_for_pane_content_regex_line_match(wait_pane: Pane) -> None:
1026991
"""Test wait_for_pane_content with regex match and line detection."""
1027992
# Clear the pane
1028993
wait_pane.send_keys("clear", enter=True)
1029-
time.sleep(0.2)
1030994

1031995
# Add multiple lines with patterns
1032996
wait_pane.send_keys("echo 'line 1 normal'", enter=True)
1033997
wait_pane.send_keys("echo 'line 2 with pattern abc123'", enter=True)
1034998
wait_pane.send_keys("echo 'line 3 normal'", enter=True)
1035-
time.sleep(0.2)
1036999

10371000
# Create a regex pattern to find the line with the number pattern
10381001
pattern = re.compile(r"pattern [a-z0-9]+")
@@ -1061,12 +1024,10 @@ def test_wait_for_all_content_with_line_range(wait_pane: Pane) -> None:
10611024
"""Test wait_for_all_content with line range specification."""
10621025
# Clear the pane first
10631026
wait_pane.send_keys("clear", enter=True)
1064-
time.sleep(0.2) # Ensure the clear command completes
10651027

10661028
# Add some content
10671029
wait_pane.send_keys("echo 'Line 1'", enter=True)
10681030
wait_pane.send_keys("echo 'Line 2'", enter=True)
1069-
time.sleep(0.2) # Wait for commands to complete
10701031

10711032
patterns: list[str | re.Pattern[str] | Callable[[list[str]], bool]] = [
10721033
"Line 1",
@@ -1092,7 +1053,6 @@ def test_wait_for_all_content_timeout(wait_pane: Pane) -> None:
10921053
"""Test wait_for_all_content timeout behavior without raising exception."""
10931054
# Clear the pane first
10941055
wait_pane.send_keys("clear", enter=True)
1095-
time.sleep(0.2) # Ensure the clear command completes
10961056

10971057
# Pattern that won't be found in the pane content
10981058
patterns: list[str | re.Pattern[str] | Callable[[list[str]], bool]] = [
@@ -1214,12 +1174,10 @@ def test_wait_for_any_content_with_predicates(wait_pane: Pane) -> None:
12141174
"""Test wait_for_any_content with predicate functions."""
12151175
# Clear and prepare pane
12161176
wait_pane.send_keys("clear", enter=True)
1217-
time.sleep(0.2)
12181177

12191178
# Add some content
12201179
wait_pane.send_keys("echo 'Line 1'", enter=True)
12211180
wait_pane.send_keys("echo 'Line 2'", enter=True)
1222-
time.sleep(0.2)
12231181

12241182
# Define two predicate functions, one that will match and one that won't
12251183
def has_two_lines(content: list[str]) -> bool:
@@ -1248,12 +1206,10 @@ def test_wait_for_pane_content_with_line_range(wait_pane: Pane) -> None:
12481206
"""Test wait_for_pane_content with line range."""
12491207
# Clear and prepare pane
12501208
wait_pane.send_keys("clear", enter=True)
1251-
time.sleep(0.2)
12521209

12531210
# Add numbered lines
12541211
for i in range(5):
12551212
wait_pane.send_keys(f"echo 'Line {i}'", enter=True)
1256-
time.sleep(0.2)
12571213

12581214
# Test with line range
12591215
result = wait_for_pane_content(
@@ -1458,7 +1414,6 @@ def test_wait_for_any_content_exact_match(wait_pane: Pane) -> None:
14581414
"""
14591415
# Clear the pane and add specific content
14601416
wait_pane.send_keys("clear", enter=True)
1461-
time.sleep(0.5) # Short delay to ensure clear happens
14621417

14631418
# Capture the current content to match it exactly later
14641419
content = wait_pane.capture_pane()
@@ -1496,7 +1451,6 @@ def test_wait_for_any_content_string_regex(wait_pane: Pane) -> None:
14961451
"""
14971452
# Clear the pane
14981453
wait_pane.send_keys("clear", enter=True)
1499-
time.sleep(0.5) # Short delay to ensure clear happens
15001454

15011455
# Add content with patterns to match
15021456
wait_pane.send_keys("Number ABC-123", enter=True)
@@ -1519,12 +1473,9 @@ def test_wait_for_any_content_string_regex(wait_pane: Pane) -> None:
15191473

15201474
# Test focusing on just the string pattern for the next test
15211475
wait_pane.send_keys("clear", enter=True)
1522-
time.sleep(0.5)
15231476

15241477
# Add only a string pattern match, ensuring it's the only match
15251478
wait_pane.send_keys("Pattern XYZ-789", enter=True)
1526-
# Wait a bit to make sure cmd is processed
1527-
time.sleep(0.5)
15281479

15291480
# First check if the content has our pattern
15301481
content = wait_pane.capture_pane()
@@ -1554,7 +1505,6 @@ def test_wait_for_all_content_predicate_match_numbering(wait_pane: Pane) -> None
15541505
"""
15551506
# Add some content to the pane
15561507
wait_pane.send_keys("clear", enter=True)
1557-
time.sleep(0.5) # Short delay to ensure clear happens
15581508

15591509
wait_pane.send_keys("Predicate Line 1", enter=True)
15601510
wait_pane.send_keys("Predicate Line 2", enter=True)
@@ -1891,11 +1841,9 @@ def test_wait_for_pane_content_exact_match_detailed(wait_pane: Pane) -> None:
18911841
"""
18921842
# Clear the pane first to have more predictable content
18931843
wait_pane.clear()
1894-
time.sleep(0.3) # Give time for clear to take effect
18951844

18961845
# Send a unique string that we can test with an exact match
18971846
wait_pane.send_keys("UNIQUE_TEST_STRING_123", literal=True)
1898-
time.sleep(0.3) # Give more time for content to appear
18991847

19001848
# Get the current content to work with
19011849
content = wait_pane.capture_pane()
@@ -1952,9 +1900,6 @@ def test_wait_for_pane_content_with_invalid_prompt(wait_pane: Pane) -> None:
19521900
wait_pane.send_keys("clear", enter=True)
19531901
wait_pane.send_keys("echo 'testing invalid prompt'", enter=True)
19541902

1955-
# Wait a bit for the command to complete
1956-
time.sleep(0.5)
1957-
19581903
# With a non-matching pattern and raises=False, should not raise but return failure
19591904
result = wait_for_pane_content(
19601905
wait_pane,

0 commit comments

Comments
 (0)