forked from goodboy/tractor
				
			Add ctl-c case to `subactor_breakpoint` example test
							parent
							
								
									ba7b355d9c
								
							
						
					
					
						commit
						a2e90194bc
					
				| 
						 | 
					@ -150,7 +150,7 @@ def do_ctlc(
 | 
				
			||||||
    child,
 | 
					    child,
 | 
				
			||||||
    count: int = 3,
 | 
					    count: int = 3,
 | 
				
			||||||
    delay: float = 0.1,
 | 
					    delay: float = 0.1,
 | 
				
			||||||
    expect_prompt: bool = False,
 | 
					    expect_prompt: bool = True,
 | 
				
			||||||
    patt: Optional[str] = None,
 | 
					    patt: Optional[str] = None,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
) -> None:
 | 
					) -> None:
 | 
				
			||||||
| 
						 | 
					@ -166,11 +166,11 @@ def do_ctlc(
 | 
				
			||||||
            time.sleep(delay)
 | 
					            time.sleep(delay)
 | 
				
			||||||
            child.expect(r"\(Pdb\+\+\)")
 | 
					            child.expect(r"\(Pdb\+\+\)")
 | 
				
			||||||
            time.sleep(delay)
 | 
					            time.sleep(delay)
 | 
				
			||||||
 | 
					            before = str(child.before.decode())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        before = str(child.before.decode())
 | 
					            if patt:
 | 
				
			||||||
        if patt:
 | 
					                # should see the last line on console
 | 
				
			||||||
            # should see the last line on console
 | 
					                assert patt in before
 | 
				
			||||||
            assert patt in before
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_root_actor_bp_forever(
 | 
					def test_root_actor_bp_forever(
 | 
				
			||||||
| 
						 | 
					@ -258,7 +258,10 @@ def test_subactor_error(
 | 
				
			||||||
    child.expect(pexpect.EOF)
 | 
					    child.expect(pexpect.EOF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_subactor_breakpoint(spawn):
 | 
					def test_subactor_breakpoint(
 | 
				
			||||||
 | 
					    spawn,
 | 
				
			||||||
 | 
					    ctlc: bool,
 | 
				
			||||||
 | 
					):
 | 
				
			||||||
    "Single subactor with an infinite breakpoint loop"
 | 
					    "Single subactor with an infinite breakpoint loop"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    child = spawn('subactor_breakpoint')
 | 
					    child = spawn('subactor_breakpoint')
 | 
				
			||||||
| 
						 | 
					@ -275,6 +278,9 @@ def test_subactor_breakpoint(spawn):
 | 
				
			||||||
        child.sendline('next')
 | 
					        child.sendline('next')
 | 
				
			||||||
        child.expect(r"\(Pdb\+\+\)")
 | 
					        child.expect(r"\(Pdb\+\+\)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ctlc:
 | 
				
			||||||
 | 
					            do_ctlc(child)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # now run some "continues" to show re-entries
 | 
					    # now run some "continues" to show re-entries
 | 
				
			||||||
    for _ in range(5):
 | 
					    for _ in range(5):
 | 
				
			||||||
        child.sendline('continue')
 | 
					        child.sendline('continue')
 | 
				
			||||||
| 
						 | 
					@ -282,6 +288,9 @@ def test_subactor_breakpoint(spawn):
 | 
				
			||||||
        before = str(child.before.decode())
 | 
					        before = str(child.before.decode())
 | 
				
			||||||
        assert "Attaching pdb to actor: ('breakpoint_forever'" in before
 | 
					        assert "Attaching pdb to actor: ('breakpoint_forever'" in before
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ctlc:
 | 
				
			||||||
 | 
					            do_ctlc(child)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # finally quit the loop
 | 
					    # finally quit the loop
 | 
				
			||||||
    child.sendline('q')
 | 
					    child.sendline('q')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,6 +301,9 @@ def test_subactor_breakpoint(spawn):
 | 
				
			||||||
    assert "RemoteActorError: ('breakpoint_forever'" in before
 | 
					    assert "RemoteActorError: ('breakpoint_forever'" in before
 | 
				
			||||||
    assert 'bdb.BdbQuit' in before
 | 
					    assert 'bdb.BdbQuit' in before
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ctlc:
 | 
				
			||||||
 | 
					        do_ctlc(child)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # quit the parent
 | 
					    # quit the parent
 | 
				
			||||||
    child.sendline('c')
 | 
					    child.sendline('c')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue