[issue39986] test_os / test_listdir failed as root-directory changed during test

Matthias Braun report at bugs.python.org
Mon Mar 16 22:22:20 EDT 2020


New submission from Matthias Braun <matthiasb at fb.com>:

The test_listdir test from Lib/test/test_os.py is using os.listdir() twice in the root directory with and without parameters and compares the results. I just had the test fail for me, because an unrelated process happened to create a file in the root directory between the two invocations of os.listdir. In my case it was rsyslog creating '/imjournal.state.tmp', but the problem is a general one.

The test failed with:
```
   ..test test_os failed -- Traceback (most recent call last):
  File "/home/matthiasb/dev/fbcpython/Lib/test/test_os.py", line 1914, in test_listdir
    self.assertEqual(set(os.listdir()), set(os.listdir(os.sep)))
AssertionError: Items in the first set but not the second:
'imjournal.state.tmp'
```

----------
components: Tests
messages: 364383
nosy: Matthias Braun
priority: normal
severity: normal
status: open
title: test_os / test_listdir failed as root-directory changed during test
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39986>
_______________________________________


More information about the Python-bugs-list mailing list