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
android: test_pipes fails #71105
Comments
test_pipes fails on an android emulator running an x86 system image at API level 21. root@generic_x86:/data/local/tmp # python -m test -v test_pipes ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 27, in testSimplePipe1
self.assertEqual(f.read(), 'HELLO WORLD #1')
AssertionError: '' != 'HELLO WORLD #1'
+ HELLO WORLD #1 ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 36, in testSimplePipe2
self.assertEqual(f.read(), 'HELLO WORLD #2')
AssertionError: '' != 'HELLO WORLD #2'
+ HELLO WORLD #2 ====================================================================== Traceback (most recent call last):
File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 45, in testSimplePipe3
self.assertEqual(f.read(), 'HELLO WORLD #2')
AssertionError: '' != 'HELLO WORLD #2'
+ HELLO WORLD #2 Ran 14 tests in 0.039s FAILED (failures=3) |
The attached patch fixes this. |
Is tr not available on Android?! I would suggest to use sed instead, but I afraid sed is not available too. What commands are available at all? |
Here is the list of commands at /system/bin on the emulator. |
Thanks for the review Serhiy. New patch attached. |
New changeset 3bad4b0f7612 by Serhiy Storchaka in branch 'default': |
LGTM. Thanks Xavier. It looks to me that there are no useful commands that can be used for testing on Android. We could use md5 or grep, but this would require rewriting tests too much for small benefit. It is better to skip tests. |
Ooops too late. Here is a new patch that replaces the tr command and allows all the tests of test_pipes to run successfully on android. |
The equivalent of used "tr" command is .upper(), not .swapcase(). Instead of the loop for s in sys.stdin.read(): sys.stdout.write(s.upper()) you can write just
But actually the loop is needed for testing purpose. while True:
b = sys.stdin.buffer.read(1)
if not b:
break
sys.stdout.buffer.write(b.upper()) And sys.executable should be escaped for the case of spaces or other special symbols in the path. All this complicates tests too much. I prefer to skip some tests on Android. |
I agree with not complicating tests too much. For the record, the pipes test suite coverage is very low and the code paths that lead to invocations of os.popen() in the pipes module are not tested when those three tests are skipped. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: