Fixes to test script for flake8

pull/32/head
Douglas Gibbons 7 years ago
parent f9b79b2e51
commit 8ed81e3803

@ -2,4 +2,6 @@ language: python
python:
- "2.7"
script: python test/wait-for-it.py
script:
- python test/wait-for-it.py

@ -1,5 +1,4 @@
import unittest
import subprocess
import shlex
from subprocess import Popen, PIPE
import os
@ -11,14 +10,13 @@ MISSING_ARGS_TEXT = "Error: you need to provide a host and port to test."
HELP_TEXT = "Usage:" # Start of help text
DIVIDE_LINE = '-'*71 # Output line of dashes
class TestWaitForIt(unittest.TestCase):
"""
TestWaitForIt tests the wait-for-it.sh shell script.
The wait-for-it.sh script is assumed to be in the parent directory to the
test script.
The wait-for-it.sh script is assumed to be in the parent directory to
the test script.
"""
class TestWaitForIt(unittest.TestCase):
def execute(self, cmd):
"""Executes a command and returns exit code, STDOUT, STDERR"""
@ -62,8 +60,8 @@ class TestWaitForIt(unittest.TestCase):
def test_no_args(self):
"""
Check that no aruments returns the missing args text and the correct
return code
Check that no aruments returns the missing args text and the
correct return code
"""
self.check_args(
"",
@ -134,7 +132,7 @@ class TestWaitForIt(unittest.TestCase):
self.check_args(
"localhost:8929 --timeout=1",
"",
".*wait-for-it.sh: timeout occurred after waiting 1 seconds for localhost:8929",
".*timeout occurred after waiting 1 seconds for localhost:8929",
124
)
@ -151,11 +149,10 @@ class TestWaitForIt(unittest.TestCase):
)
soc.close()
def test_failed_command_execution(self):
"""
Check command failure. The command in question outputs STDERR and an
exit code of 2
Check command failure. The command in question outputs STDERR and
an exit code of 2
"""
soc = self.open_local_port(port=8929)
self.check_args(
@ -166,7 +163,6 @@ class TestWaitForIt(unittest.TestCase):
)
soc.close()
def test_command_after_connection_failure(self):
"""
Test that a command still runs even if a connection times out
@ -175,10 +171,9 @@ class TestWaitForIt(unittest.TestCase):
self.check_args(
"localhost:8929 --timeout=1 -- echo \"CMD OUTPUT\"",
"CMD OUTPUT",
".*wait-for-it.sh: timeout occurred after waiting 1 seconds for localhost:8929",
".*timeout occurred after waiting 1 seconds for localhost:8929",
0
)
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save