Message 177675 - Python tracker (original) (raw)

Openstack recently switched from nose to using discover. discover walks the filesystem using os.listdir(), and that is just a thin layer over readdir. On ext3/ext4 filesystems, readdir is in an arbitrary order dependent on file insertion into the directory if dir_index is enabled (which is the default).

This means that files are loaded in an order that isn't reproducable by other developers, so bad tests that have isolation issues can be very tricky to track down.

Just wrapping the os.listdir() in sorted() would be sufficient to make this robust and repeatable, and avoid the headache.