1
0
Fork 0

Work around a race condition when reading tee output.

This commit is contained in:
Irina Truong 2017-10-06 11:19:44 -07:00
parent 915ffb70a7
commit 1a7a823169
4 changed files with 16 additions and 8 deletions

View File

@ -6,8 +6,8 @@ python:
- "3.5"
- "3.6"
install:
- pip install . docutils pytest mock codecov==1.5.1 behave pexpect==3.3
install:
- pip install . docutils pytest mock codecov==1.5.1 behave pexpect==3.3 retrying>=1.3.3
- pip install git+https://github.com/hayd/pep8radius.git
script:

View File

@ -4,4 +4,6 @@ tox>=1.9.2
behave>=1.2.4
pexpect==3.3
coverage==4.3.4
pep8radius
pep8radius>=0.9.2
retrying>=1.3.3

View File

@ -12,6 +12,6 @@ Feature: I/O commands
and we wait for prompt
and we query "select 123456"
and we wait for prompt
and we notee output
and we stop teeing output
and we wait for prompt
then we see 123456 in tee output

View File

@ -5,6 +5,7 @@ import os.path
import wrappers
from behave import when, then
from retrying import retry
@when('we start external editor providing a file name')
@ -67,16 +68,21 @@ def step_query_select_123456(context):
context.cli.sendline('select 123456')
@when(u'we notee output')
@when(u'we stop teeing output')
def step_notee_output(context):
context.cli.sendline('notee')
context.cli.sendline('\o')
wrappers.expect_exact(context, "Time", timeout=5)
@then(u'we see 123456 in tee output')
def step_see_123456_in_ouput(context):
with open(context.tee_file_name) as f:
assert '123456' in f.read()
@retry(stop_max_delay=3000) # stop trying after 3 seconds
def assert_tee_output():
with open(context.tee_file_name) as f:
assert '123456' in f.read()
assert_tee_output()
if os.path.exists(context.tee_file_name):
os.remove(context.tee_file_name)
context.atprompt = True