Title: test_pkg test_4 and/or test_7 sometimes fail
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.6, Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: importlib: python -m test test_pkg fails semi-randomly
View: 34200
Assigned To: Nosy List: brett.cannon, eric.snow, martin.panter, ncoghlan, superluser, xtreak
Priority: normal Keywords: 3.4regression, patch

Created on 2016-01-18 05:27 by martin.panter, last changed 2018-09-24 15:23 by xtreak. This issue is now closed.

File name Uploaded Description Edit
revert-bootlocale.patch martin.panter, 2016-01-21 11:11 review
Messages (6)
msg258500 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-18 05:27
It doesn’t always fail, and sometimes only one or the other test fails. Also, it seems to depend on the way the tests are run. I have never seen it fail with “python -m test -v”. Two commands where it does often fail for me:

./python -m test -w test_pkg
./python -m unittest -v test.test_pkg

Here is the output when both tests fail:

test_1 (test.test_pkg.TestPkg) ... ok
test_2 (test.test_pkg.TestPkg) ... ok
test_3 (test.test_pkg.TestPkg) ... ok
test_4 (test.test_pkg.TestPkg) ... ERROR
test_5 (test.test_pkg.TestPkg) ... ok
test_6 (test.test_pkg.TestPkg) ... ok
test_7 (test.test_pkg.TestPkg) ... FAIL
test_8 (test.test_pkg.TestPkg) ... ok

ERROR: test_4 (test.test_pkg.TestPkg)
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/test/", line 180, in test_4
  File "/media/disk/home/proj/python/cpython/Lib/test/", line 69, in run_code
    exec(textwrap.dedent(code), globals(), {"self": self})
  File "<string>", line 2, in <module>
  File "/tmp/tmprhpx80bw/", line 1, in <module>
RuntimeError: Shouldnt load

FAIL: test_7 (test.test_pkg.TestPkg)
Traceback (most recent call last):
  File "/media/disk/home/proj/python/cpython/Lib/test/", line 260, in test_7
    '__name__', '__package__', '__path__', '__spec__'])
AssertionError: Lists differ: ['__c[34 chars]__loader__', '__name__', '__package__', '__spec__'] != ['__c[34 chars]__loader__', '__name__', '__package__', '__path__', '__spec__']

First differing element 6:

Second list contains 1 additional elements.
First extra element 7:

+  '__path__',

Ran 8 tests in 0.038s

FAILED (failures=1, errors=1)
msg258605 - (view) Author: Rose Ames (superluser) * Date: 2016-01-19 16:08
Reproduced.  In four runs, one errored in test_4, one failed in test_7, and the other two did both.
msg258609 - (view) Author: Rose Ames (superluser) * Date: 2016-01-19 16:35
redirecting stdout seems to reliably suppress both failures:

$ ./python -m test -w test_pkg >foo
$ cat foo
[1/1] test_pkg
1 test OK.
msg258755 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-01-21 11:11
I think I traced this to revision fbbf8b160e8d (Issue 9548, Python 3.4). Before that revision, I haven’t been able to produce the failures. Also, reverting that change in the current default branch seems to stop the failures. Attached is the patch that reverts the change, though I am not suggesting that is the ultimate fix.

FTR my main setup is x86-64 Arch Linux; I also see this on a 32-bit Linux computer.
msg326159 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-23 15:36
I think this was fixed with though the patch was not applied to 3.5 and 3.4 as they are in security bug fixes mode.

msg326248 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python committer) Date: 2018-09-24 15:23
I am closing this issue as duplicate as part of triaging adding issue34200 as superseder that reports the same error along with a PR and discussion. There have been no failures reported with respect to test_pkg after the fix was merged. Feel free to reopen this if needed.

Date User Action Args
2018-09-24 15:23:59xtreaksetstatus: open -> closed
superseder: importlib: python -m test test_pkg fails semi-randomly
messages: + msg326248

resolution: duplicate
stage: resolved
2018-09-23 15:36:15xtreaksetnosy: + xtreak
messages: + msg326159
2016-01-21 11:28:47serhiy.storchakasetnosy: + brett.cannon, ncoghlan, eric.snow
2016-01-21 11:11:04martin.pantersetkeywords: + 3.4regression, patch
files: + revert-bootlocale.patch
messages: + msg258755
2016-01-19 16:35:43superlusersetmessages: + msg258609
2016-01-19 16:08:19superlusersetnosy: + superluser
messages: + msg258605
2016-01-18 05:27:40martin.pantercreate