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

Commit

Permalink
Add 300 rounds of test_sh_captures_output_in_correct_order, because o…
Browse files Browse the repository at this point in the history
…f the test specifics - timing
  • Loading branch information
blackandred committed May 14, 2020
1 parent c6a50ce commit ab4a28d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions test/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,28 @@ def test():
self.assertRaises(Exception, test)

def test_sh_captures_output_in_correct_order(self):
self.maxDiff = None # unittest setting
task = InitTask()
#
# Perform 300 rounds of test to prove it is working as expected
#
for i in range(1, 300):
self.maxDiff = None # unittest setting
task = InitTask()

io = IO()
out = StringIO()
io = IO()
out = StringIO()

with io.capture_descriptors(stream=out, enable_standard_out=False):
task.sh(''' set +e;
sleep 0.5;
echo "FIRST";
sleep 0.5;
echo "SECOND" >&2;
echo "THIRD";
echo "FOURTH" >&2;
echo "FIFTH" >&2;
''')
with io.capture_descriptors(stream=out, enable_standard_out=False):
task.sh(''' set +e;
sleep 0.1;
echo "FIRST";
sleep 0.1;
echo "SECOND" >&2;
echo "THIRD";
echo "FOURTH" >&2;
echo "FIFTH" >&2;
''')

self.assertEqual("FIRST\nSECOND\nTHIRD\nFOURTH\nFIFTH\n", out.getvalue())
self.assertEqual("FIRST\nSECOND\nTHIRD\nFOURTH\nFIFTH\n", out.getvalue())

def test_sh_provides_stdout_and_stderr_in_exception(self):
task = InitTask()
Expand Down

0 comments on commit ab4a28d

Please sign in to comment.