This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: android: test_pipes fails
Type: behavior Stage: resolved
Components: Cross-Build, Library (Lib) Versions: Python 3.6
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, python-dev, serhiy.storchaka, xdegaye
Priority: normal Keywords: patch

Created on 2016-05-03 09:13 by xdegaye, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
no_tr_skipped.patch xdegaye, 2016-05-04 20:07 review
emulator_system_bin.txt xdegaye, 2016-05-05 07:12 list of emulator commands
no_tr_skipped_2.patch xdegaye, 2016-05-05 07:14 review
replace_tr.patch xdegaye, 2016-05-05 08:04 replace tr with a python command review
Messages (10)
msg264702 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-03 09:13
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
== CPython 3.6.0a0 (default:f4c6dab59cd8+, May 3 2016, 10:42:45) [GCC 4.9 20140827 (prerelease)]
==   Linux-3.4.67+-i686-with-libc little-endian
==   hash algorithm: fnv 32bit
==   /data/local/tmp/test_python_1927
Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomiza
tion=1, isolated=0)
Run tests sequentially
0:00:00 [1/1] test_pipes
testBadAppendOptions (test.test_pipes.SimplePipeTests) ... ok
testBadOpenMode (test.test_pipes.SimplePipeTests) ... ok
testBadPrependOptions (test.test_pipes.SimplePipeTests) ... ok
testClone (test.test_pipes.SimplePipeTests) ... ok
testEmptyPipeline1 (test.test_pipes.SimplePipeTests) ... ok
testEmptyPipeline2 (test.test_pipes.SimplePipeTests) ... ok
testEmptyPipeline3 (test.test_pipes.SimplePipeTests) ... ok
testReadOpenSink (test.test_pipes.SimplePipeTests) ... ok
testRepr (test.test_pipes.SimplePipeTests) ... ok
testSetDebug (test.test_pipes.SimplePipeTests) ... ok
testSimplePipe1 (test.test_pipes.SimplePipeTests) ... /system/bin/sh: tr: not found
testSimplePipe2 (test.test_pipes.SimplePipeTests) ... sh: tr: not found
testSimplePipe3 (test.test_pipes.SimplePipeTests) ... /system/bin/sh: tr: not found
testWriteOpenSource (test.test_pipes.SimplePipeTests) ... ok

FAIL: testSimplePipe1 (test.test_pipes.SimplePipeTests)
Traceback (most recent call last):
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/", line 27, in testSimplePipe1
    self.assertEqual(, 'HELLO WORLD #1')
AssertionError: '' != 'HELLO WORLD #1'

FAIL: testSimplePipe2 (test.test_pipes.SimplePipeTests)
Traceback (most recent call last):
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/", line 36, in testSimplePipe2
    self.assertEqual(, 'HELLO WORLD #2')
AssertionError: '' != 'HELLO WORLD #2'

FAIL: testSimplePipe3 (test.test_pipes.SimplePipeTests)
Traceback (most recent call last):
  File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/", line 45, in testSimplePipe3
    self.assertEqual(, 'HELLO WORLD #2')
AssertionError: '' != 'HELLO WORLD #2'

Ran 14 tests in 0.039s

FAILED (failures=3)
test test_pipes failed
1 test failed:
Total duration: 0:00:01
msg264855 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-04 20:07
The attached patch fixes this.
msg264860 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-04 20:29
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?
msg264882 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-05 07:12
Here is the list of commands at /system/bin on the emulator.
msg264883 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-05 07:14
Thanks for the review Serhiy. New patch attached.
msg264886 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-05-05 07:56
New changeset 3bad4b0f7612 by Serhiy Storchaka in branch 'default':
Issue #26918: Skipped some tests in test_pipes on Android.
msg264887 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-05 08:00
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.
msg264888 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-05 08:04
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.
msg264906 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-05-05 12:40
The equivalent of used "tr" command is .upper(), not .swapcase().

Instead of the loop

    for s in sys.stdout.write(s.upper())

you can write just


But actually the loop is needed for testing purpose.

    while True:
        b =
        if not b:

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.
msg264908 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2016-05-05 15:22
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.
Date User Action Args
2022-04-11 14:58:30adminsetgithub: 71105
2016-05-21 07:06:39xdegayelinkissue26865 dependencies
2016-05-05 15:22:48xdegayesetmessages: + msg264908
2016-05-05 12:40:02serhiy.storchakasetmessages: + msg264906
2016-05-05 08:04:42xdegayesetfiles: + replace_tr.patch

messages: + msg264888
2016-05-05 08:00:25serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg264887

stage: resolved
2016-05-05 07:56:27python-devsetnosy: + python-dev
messages: + msg264886
2016-05-05 07:15:00xdegayesetfiles: + no_tr_skipped_2.patch

messages: + msg264883
2016-05-05 07:12:30xdegayesetfiles: + emulator_system_bin.txt

messages: + msg264882
2016-05-04 20:29:59serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg264860
2016-05-04 20:07:38xdegayesetfiles: + no_tr_skipped.patch
keywords: + patch
messages: + msg264855
2016-05-03 09:13:44xdegayecreate