Skip to content

Commit 9bf4974

Browse files
committed
fixing test, wait before server is up or down
1 parent cad7608 commit 9bf4974

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

test/ServerTest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@ class ServerTest(unittest.TestCase):
66
def test_request(self):
77
serverProc = subprocess.Popen(['python', '../src/server.py'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
88
sleep(1)
9-
self.assertEqual(None, serverProc.poll(), "Server exited unexpectedly")
9+
self.assertEqual(None, serverProc.poll())
1010
test_data = "1234567890asdf"
1111
resp = requests.get("http://localhost:5000?oauth_verifier=%s" % test_data)
1212
assert resp.status_code == 200
1313
with self.assertRaises(requests.ConnectionError):
1414
resp = requests.get("http://localhost:5000?oauth_verifier=%s" % test_data)
1515

16-
status = serverProc.poll()
17-
if status is None:
16+
polls = 0
17+
while serverProc.poll() is None and polls < 10:
18+
polls += 1
19+
sleep(1)
20+
21+
if serverProc.poll() is None:
1822
serverProc.kill()
1923
self.fail("Server process is still alive, killing now...")
2024
stdout, stderr = serverProc.communicate()

0 commit comments

Comments
 (0)