Skip to content
Snippets Groups Projects
Commit 7f645ced authored by Douglas Gibbons's avatar Douglas Gibbons
Browse files

Start of test framework

parent ac372412
No related branches found
No related tags found
No related merge requests found
**/*.pyc
.pydevproject
language: python
python:
- "2.7"
script: python test/wait-for-it.py
import unittest
import subprocess
import shlex
from subprocess import Popen, PIPE
import os
import sys
class TestWaitForIt(unittest.TestCase):
def execute(self,cmd):
"""Executes a command and returns exit code, STDOUT, STDERR"""
args = shlex.split(cmd)
proc = Popen(args, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
exitcode = proc.returncode
return exitcode, out, err
def setUp(self):
script_path = os.path.dirname(sys.argv[0])
parent_path = os.path.abspath(os.path.join(script_path, os.pardir))
self.wait_script = os.path.join(parent_path,"wait-for-it.sh")
def test_no_args_return_code(self):
# Return code should be 1 when called with no args
exitcode, out, err = self.execute(self.wait_script)
self.assertEqual(exitcode,1)
def test_help(self):
exitcode, out, err = self.execute(self.wait_script+" --help")
# STDERR should begin with "Usage:"
self.assertTrue(err.startswith("Usage:"))
# exit code should be 1
self.assertEqual(exitcode,1)
if __name__ == '__main__':
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment