Skip to content

Commit

Permalink
Merge pull request #8 from sot/fix-tests
Browse files Browse the repository at this point in the history
Fix tests and mistake in bash/tcsh_shell function signatures
  • Loading branch information
taldcroft authored Jul 20, 2017
2 parents 25fa247 + 6ecd703 commit 006141d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Ska/Shell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .shell import *

__version__ = '3.3.1'
__version__ = '3.3.2'


def test(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions Ska/Shell/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def bash_shell(cmdstr, logfile=None, importenv=False, getenv=False, env=None):
:rtype: (outlines, deltaenv)
"""
outlines, newenv = run_shell(cmdstr, shell='bash', logfile=logfile,
importenv=importenv, env=env)
importenv=importenv, getenv=getenv, env=env)
return outlines, newenv


Expand Down Expand Up @@ -257,7 +257,7 @@ def tcsh_shell(cmdstr, logfile=None, importenv=False, getenv=False, env=None):
:rtype: (outlines, deltaenv)
"""
outlines, newenv = run_shell(cmdstr, shell='tcsh', logfile=logfile,
importenv=importenv, env=env)
importenv=importenv, getenv=getenv, env=env)
return outlines, newenv


Expand Down
28 changes: 14 additions & 14 deletions Ska/Shell/tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@ def test_bash_shell(self):
assert env == {}

def test_env(self):
envs = getenv('export TEST_ENV_VAR="hello"')
assert envs['TEST_ENV_VAR'] == 'hello'
outlines = bash('echo $TEST_ENV_VAR', env=envs)
envs = getenv('export TEST_ENV_VARA="hello"')
assert envs['TEST_ENV_VARA'] == 'hello'
outlines = bash('echo $TEST_ENV_VARA', env=envs)
assert outlines == ['hello']

def test_importenv(self):
importenv('export TEST_ENV_VAR="hello"', env={'TEST_ENV_VAR2': 'world'})
assert os.environ['TEST_ENV_VAR'] == 'hello'
assert os.environ['TEST_ENV_VAR2'] == 'world'
importenv('export TEST_ENV_VARC="hello"', env={'TEST_ENV_VARB': 'world'})
assert os.environ['TEST_ENV_VARC'] == 'hello'
assert os.environ['TEST_ENV_VARB'] == 'world'

def test_logfile(self):
logfile = StringIO()
bash('echo line1; echo line2', logfile=logfile)
logfile.seek(0)
outlines = logfile.read().splitlines()
assert outlines[0].startswith('Bash-')
cmd = 'echo line1; echo line2'
bash(cmd, logfile=logfile)
outlines = logfile.getvalue().splitlines()
assert outlines[0].endswith(cmd)
assert outlines[1] == 'line1'
assert outlines[2] == 'line2'
assert outlines[3].startswith('Bash')
Expand Down Expand Up @@ -115,11 +115,11 @@ def test_importenv(self):

def test_logfile(self, tmpdir):
logfile = StringIO()
tcsh('echo line1; echo line2', logfile=logfile)
logfile.seek(0)
out = logfile.read()
cmd = 'echo line1; echo line2'
tcsh(cmd, logfile=logfile)
out = logfile.getvalue()
outlines = out.strip().splitlines()
assert outlines[0].startswith('Tcsh-')
assert outlines[0].endswith(cmd)
assert outlines[1] == ''
assert outlines[2] == 'line1'
assert outlines[3] == 'line2'
Expand Down

0 comments on commit 006141d

Please sign in to comment.