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

test_spawn_sh occasionally fails #73

Open
kulikjak opened this issue Sep 30, 2022 · 0 comments
Open

test_spawn_sh occasionally fails #73

kulikjak opened this issue Sep 30, 2022 · 0 comments

Comments

@kulikjak
Copy link

When I started testing ptyprocess with Python 3.11 I found out that test_spawn_sh fails with:

E       AssertionError: assert b'echo $ENV_KEY; exit 0' in b'\rjkulik@kuldavm-sparc-6717:...process/ptyprocess-0.7.0/tests$ echo $ENV \x08_KEY; exit 0\r\nenv_value\r\n'                                                
E        +  where b'echo $ENV_KEY; exit 0' = <built-in method strip of bytes object at 0x1fffc6b2a9f8b0>()                                                                                                              
E        +    where <built-in method strip of bytes object at 0x1fffc6b2a9f8b0> = b'echo $ENV_KEY; exit 0\n'.strip

I did some testing and it seems that this is caused by some kind of a race condition / it's speed dependent. When I run the test suite for the second time, it passes. But then when I delete the __pycache__ directory, it fails again.

I also found out that when I add a sleep after the spawn, it fails every time in every Python (and not just this test, test_spawn_sh_unicode as well):

--- ptyprocess-0.7.0/tests/test_spawn.py
+++ ptyprocess-0.7.0/tests/test_spawn.py
@@ -21,6 +21,7 @@ class PtyTestCase(unittest.TestCase):
     def _spawn_sh(self, ptyp, cmd, outp, env_value):
         # given,
         p = ptyp.spawn(['sh'], env=self.env)
+        time.sleep(1)
         p.write(cmd)
 
         # exercise,
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

1 participant