Extract child flush as a staticmethod
This commit is contained in:
		
							parent
							
								
									82fb63ca2d
								
							
						
					
					
						commit
						11ec96a927
					
				| 
						 | 
					@ -76,6 +76,10 @@ class TestPDB:
 | 
				
			||||||
        rest = child.read().decode("utf8")
 | 
					        rest = child.read().decode("utf8")
 | 
				
			||||||
        assert "1 failed" in rest
 | 
					        assert "1 failed" in rest
 | 
				
			||||||
        assert "def test_1" not in rest
 | 
					        assert "def test_1" not in rest
 | 
				
			||||||
 | 
					        self.flush(child)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @staticmethod
 | 
				
			||||||
 | 
					    def flush(child):
 | 
				
			||||||
        if child.isalive():
 | 
					        if child.isalive():
 | 
				
			||||||
            child.wait()
 | 
					            child.wait()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,8 +99,7 @@ class TestPDB:
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        rest = child.read().decode("utf8")
 | 
					        rest = child.read().decode("utf8")
 | 
				
			||||||
        assert 'debug.me' in rest
 | 
					        assert 'debug.me' in rest
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_capture(self, testdir):
 | 
					    def test_pdb_interaction_capture(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -111,8 +114,7 @@ class TestPDB:
 | 
				
			||||||
        rest = child.read().decode("utf8")
 | 
					        rest = child.read().decode("utf8")
 | 
				
			||||||
        assert "1 failed" in rest
 | 
					        assert "1 failed" in rest
 | 
				
			||||||
        assert "getrekt" not in rest
 | 
					        assert "getrekt" not in rest
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_exception(self, testdir):
 | 
					    def test_pdb_interaction_exception(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -130,8 +132,7 @@ class TestPDB:
 | 
				
			||||||
        child.expect(".*function")
 | 
					        child.expect(".*function")
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        child.expect("1 failed")
 | 
					        child.expect("1 failed")
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_on_collection_issue181(self, testdir):
 | 
					    def test_pdb_interaction_on_collection_issue181(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -143,8 +144,7 @@ class TestPDB:
 | 
				
			||||||
        child.expect("(Pdb)")
 | 
					        child.expect("(Pdb)")
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        child.expect("1 error")
 | 
					        child.expect("1 error")
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_on_internal_error(self, testdir):
 | 
					    def test_pdb_interaction_on_internal_error(self, testdir):
 | 
				
			||||||
        testdir.makeconftest("""
 | 
					        testdir.makeconftest("""
 | 
				
			||||||
| 
						 | 
					@ -156,8 +156,7 @@ class TestPDB:
 | 
				
			||||||
        #child.expect(".*import pytest.*")
 | 
					        #child.expect(".*import pytest.*")
 | 
				
			||||||
        child.expect("(Pdb)")
 | 
					        child.expect("(Pdb)")
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_capturing_simple(self, testdir):
 | 
					    def test_pdb_interaction_capturing_simple(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -177,8 +176,7 @@ class TestPDB:
 | 
				
			||||||
        assert "1 failed" in rest
 | 
					        assert "1 failed" in rest
 | 
				
			||||||
        assert "def test_1" in rest
 | 
					        assert "def test_1" in rest
 | 
				
			||||||
        assert "hello17" in rest # out is captured
 | 
					        assert "hello17" in rest # out is captured
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_set_trace_interception(self, testdir):
 | 
					    def test_pdb_set_trace_interception(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -193,8 +191,7 @@ class TestPDB:
 | 
				
			||||||
        rest = child.read().decode("utf8")
 | 
					        rest = child.read().decode("utf8")
 | 
				
			||||||
        assert "1 failed" in rest
 | 
					        assert "1 failed" in rest
 | 
				
			||||||
        assert "reading from stdin while output" not in rest
 | 
					        assert "reading from stdin while output" not in rest
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_and_capsys(self, testdir):
 | 
					    def test_pdb_and_capsys(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -209,8 +206,7 @@ class TestPDB:
 | 
				
			||||||
        child.expect("hello1")
 | 
					        child.expect("hello1")
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        child.read()
 | 
					        child.read()
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_set_trace_capturing_afterwards(self, testdir):
 | 
					    def test_set_trace_capturing_afterwards(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -229,8 +225,7 @@ class TestPDB:
 | 
				
			||||||
        child.expect("hello")
 | 
					        child.expect("hello")
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        child.read()
 | 
					        child.read()
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_doctest(self, testdir):
 | 
					    def test_pdb_interaction_doctest(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -249,8 +244,7 @@ class TestPDB:
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        rest = child.read().decode("utf8")
 | 
					        rest = child.read().decode("utf8")
 | 
				
			||||||
        assert "1 failed" in rest
 | 
					        assert "1 failed" in rest
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_interaction_capturing_twice(self, testdir):
 | 
					    def test_pdb_interaction_capturing_twice(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -276,8 +270,7 @@ class TestPDB:
 | 
				
			||||||
        assert "def test_1" in rest
 | 
					        assert "def test_1" in rest
 | 
				
			||||||
        assert "hello17" in rest # out is captured
 | 
					        assert "hello17" in rest # out is captured
 | 
				
			||||||
        assert "hello18" in rest # out is captured
 | 
					        assert "hello18" in rest # out is captured
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_used_outside_test(self, testdir):
 | 
					    def test_pdb_used_outside_test(self, testdir):
 | 
				
			||||||
        p1 = testdir.makepyfile("""
 | 
					        p1 = testdir.makepyfile("""
 | 
				
			||||||
| 
						 | 
					@ -331,8 +324,7 @@ class TestPDB:
 | 
				
			||||||
        child.expect("enter_pdb_hook")
 | 
					        child.expect("enter_pdb_hook")
 | 
				
			||||||
        child.send('c\n')
 | 
					        child.send('c\n')
 | 
				
			||||||
        child.sendeof()
 | 
					        child.sendeof()
 | 
				
			||||||
        if child.isalive():
 | 
					        self.flush(child)
 | 
				
			||||||
            child.wait()
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_pdb_custom_cls(self, testdir):
 | 
					    def test_pdb_custom_cls(self, testdir):
 | 
				
			||||||
        called = []
 | 
					        called = []
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue