Skip to content

Commit

Permalink
Add: test to show that an Action stderr output must be used if stdout…
Browse files Browse the repository at this point in the history
… is empty and exit_status != 0
  • Loading branch information
Grégory Starck committed Feb 6, 2015
1 parent b4597a6 commit f8fdb6c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions test/test_action.py
Expand Up @@ -24,10 +24,12 @@

import os
import sys
import time

from shinken_test import *
from shinken_test import ShinkenTest, unittest, time_hacker
from shinken.action import Action


class TestAction(ShinkenTest):
def setUp(self):
self.setup_with_file('etc/shinken_1r_1h_1s.cfg')
Expand Down Expand Up @@ -250,8 +252,6 @@ def test_huge_output(self):
self.assertEqual("A"*100000, a.output)
self.assertEqual("", a.perf_data)



def test_execve_fail_with_utf8(self):
if os.name == 'nt':
return
Expand All @@ -267,10 +267,15 @@ def test_execve_fail_with_utf8(self):
#print a.output
self.assertEqual(a.output.decode('utf8'), u"Wiadomo\u015b\u0107")

def test_non_zero_exit_status_empty_output_but_non_empty_stderr(self):
a = Action()
a.command = "echo hooo >&2 ; exit 1"
a.timeout = 10
a.env = {} # :fixme: this sould be pre-set in Action.__init__()
a.execute()
self.wait_finished(a)
self.assertEqual(a.output, "hooo")


if __name__ == '__main__':
import sys

#os.chdir(os.path.dirname(sys.argv[0]))
unittest.main()

0 comments on commit f8fdb6c

Please sign in to comment.