Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition (fail) in tests.test_spawn.PtyTestCase.test_spawn_sh_unicode #25

Open
jquast opened this issue Sep 16, 2015 · 1 comment

Comments

@jquast
Copy link
Member

jquast commented Sep 16, 2015

The test is likely at fault. It is attempting to see its own keyboard input in output, but the prompt is displaying late, causing the familiar "input echo intermittently spanned in output" condition:

AssertionError: assert 'echo $ENV_KEY; exit 0' in 'echo $EN(teamcity-pexpect)(teamcity-pexpect)V_KEY; exit 0\r\nenv_value\r\n' 

Full output and link

self = <tests.test_spawn.PtyTestCase testMethod=test_spawn_sh_unicode>
ptyp = <class 'ptyprocess.ptyprocess.PtyProcessUnicode'>
cmd = 'echo $ENV_KEY; exit 0\n'
outp = 'echo $EN(teamcity-pexpect)(teamcity-pexpect)V_KEY; exit 0\r\nenv_value\r\n'
env_value = 'env_value'

    def _spawn_sh(self, ptyp, cmd, outp, env_value):
        # given,
        p = ptyp.spawn(['sh'], env=self.env)
        p.write(cmd)

        # exercise,
        while True:
            try:
                outp += p.read()
            except EOFError:
                break

        # verify, input is echo to output
>       assert cmd.strip() in outp
E       AssertionError: assert 'echo $ENV_KEY; exit 0' in 'echo $EN(teamcity-pexpect)(teamcity-pexpect)V_KEY; exit 0\r\nenv_value\r\n'
E        +  where 'echo $ENV_KEY; exit 0' = <built-in method strip of str object at 0x7f2231b5f540>()
E        +    where <built-in method strip of str object at 0x7f2231b5f540> = 'echo $ENV_KEY; exit 0\n'.strip

https://teamcity-master.pexpect.org/viewLog.html?buildId=13605&buildTypeId=Pexpect_LinuxBuild&tab=buildLog

@takluyver
Copy link
Member

I guess we need to add some kind of wait (either sleep or check for a condition) to ensure the prompt is displayed before we send input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants