New submission from Dennis Sweeney <sweeney.dennis...@gmail.com>:

I get the following intermittent failure when running the tests on Master on 
Windows 10.

=================================
=================================
=================================


PS C:\...\cpython> .\python.bat -m unittest -v 
test.test_os.TestScandir.test_attributes
Running Release|Win32 interpreter...
test_attributes (test.test_os.TestScandir) ... ok

----------------------------------------------------------------------
Ran 1 test in 0.005s

OK
PS C:\...\cpython> .\python.bat -m unittest -v 
test.test_os.TestScandir.test_attributes
Running Release|Win32 interpreter...
test_attributes (test.test_os.TestScandir) ... FAIL

======================================================================
FAIL: test_attributes (test.test_os.TestScandir)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\...\cpython\lib\test\test_os.py", line 3900, in test_attributes
    self.check_entry(entry, 'link_file.txt', False, True, False)
  File "C:\...\cpython\lib\test\test_os.py", line 3861, in check_entry
    self.assert_stat_equal(entry.stat(),
  File "C:\...\cpython\lib\test\test_os.py", line 3822, in assert_stat_equal
    self.assertEqual(getattr(stat1, attr),
AssertionError: 1587065935.7958326 != 1587065935.79683 : 
(os.stat_result(st_mode=33206, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, 
st_gid=0, st_size=6, st_atime=1587065935, st_mtime=1587065935, 
st_ctime=1587065935), os.stat_result(st_mode=33206, st_ino=2533274791602992, 
st_dev=839545721, st_nlink=2, st_uid=0, st_gid=0, st_size=6, 
st_atime=1587065935, st_mtime=1587065935, st_ctime=1587065935), 'st_atime')

----------------------------------------------------------------------
Ran 1 test in 0.007s

FAILED (failures=1)

=================================
=================================
=================================


The failure seems to happen only about one in every 3 or 4 runs. Maybe this is 
unrelated, but I'm a little confused about why the repr of os.stat_result makes 
it look like st_atime is an int, but when accessing with .st_atime, we get a 
float that seems to just be st_atime_ns * 10**-9. I ran pdb during the failing 
test and got this:


=================================
=================================
=================================

-> self.assertEqual(getattr(stat1, attr),
(Pdb) stat1
os.stat_result(st_mode=33206, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, 
st_gid=0, st_size=6, st_atime=1587071882, st_mtime=1587071882, 
st_ctime=1587071882)
(Pdb) stat1
os.stat_result(st_mode=33206, st_ino=0, st_dev=0, st_nlink=0, st_uid=0, 
st_gid=0, st_size=6, st_atime=1587071882, st_mtime=1587071882, 
st_ctime=1587071882)
(Pdb) stat1.st_atime == stat2.st_atime
False
(Pdb) stat1.st_atime
1587071882.6492443
(Pdb) stat2.st_atime
1587071882.6502416
(Pdb) stat1.st_atime_ns
1587071882649244400
(Pdb) stat2.st_atime_ns
1587071882650241700
(Pdb) dir(stat1)
['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', 
'__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', 
'__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', 
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 
'count', 'index', 'n_fields', 'n_sequence_fields', 'n_unnamed_fields', 
'st_atime', 'st_atime_ns', 'st_ctime', 'st_ctime_ns', 'st_dev', 
'st_file_attributes', 'st_gid', 'st_ino', 'st_mode', 'st_mtime', 'st_mtime_ns', 
'st_nlink', 'st_reparse_tag', 'st_size', 'st_uid']
(Pdb) dir(stat2)
['__add__', '__class__', '__class_getitem__', '__contains__', '__delattr__', 
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', 
'__getitem__', '__getnewargs__', '__gt__', '__hash__', '__init__', 
'__init_subclass__', '__iter__', '__le__', '__len__', '__lt__', '__module__', 
'__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', 
'__rmul__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 
'count', 'index', 'n_fields', 'n_sequence_fields', 'n_unnamed_fields', 
'st_atime', 'st_atime_ns', 'st_ctime', 'st_ctime_ns', 'st_dev', 
'st_file_attributes', 'st_gid', 'st_ino', 'st_mode', 'st_mtime', 'st_mtime_ns', 
'st_nlink', 'st_reparse_tag', 'st_size', 'st_uid']
(Pdb) tuple(stat1)
(33206, 0, 0, 0, 0, 0, 6, 1587071882, 1587071882, 1587071882)
(Pdb) tuple(stat2)
(33206, 9851624185502411, 839545721, 2, 0, 0, 6, 1587071882, 1587071882, 
1587071882)
(Pdb)

=================================
=================================
=================================

----------
components: Windows
messages: 366631
nosy: Dennis Sweeney, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Intermittent failure of test_os.TestScandir.test_attributes on Windows
type: behavior
versions: Python 3.9

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40308>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to