Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
#47: Escape dollar character - tests coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
blackandred committed Aug 22, 2020
1 parent f3bed3e commit 22c5c14
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test_taskutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,34 @@ def test_sh_rkd_in_rkd_shows_first_lines_on_error(self):
self.assertIn('Bartolomeo Vanzetti', out.getvalue(),
msg='Expected that output will be shown for std_redirect=%s' % std_redirect)

def test_dollar_symbols_are_escaped_in_shell_commands(self):
"""Check that in envrionment variable there can be defined a value that contains dollar symbols"""

task = InitTask()
task._io = IO()
io = IO()
out = StringIO()

with io.capture_descriptors(stream=out, enable_standard_out=False):
task.sh('env | grep TEST_ENV', env={
'TEST_ENV': 'Mikhail$1Bakunin$PATHtest'
})

self.assertIn('TEST_ENV=Mikhail$1Bakunin$PATHtest', out.getvalue())

def test_quotes_are_escaped_in_shell_commands(self):
task = InitTask()
task._io = IO()
io = IO()
out = StringIO()

with io.capture_descriptors(stream=out, enable_standard_out=False):
task.sh('echo ${NAME}', env={
'NAME': 'Ferdinando "Nicola" Sacco'
})

self.assertIn('Ferdinando "Nicola" Sacco', out.getvalue())

def test_sh_3rd_depth_rkd_calls(self):
"""Bugfix: sh() of 3-depth calls -> test -> rkd -> rkd returns first line of output
"""
Expand Down

0 comments on commit 22c5c14

Please sign in to comment.