Closed bhdn closed 11 years ago
Hmm I'm not quite sure if the fix is correct because it is possible that abs(hdr.mtime - st.st_mtime) > 0.5. IMHO the "correct" fix is to use something like: self.assertEqual(hdr.mtime, int(st.st_mtime)) because hdr.mtime == floor(st.st_mtime) should always hold.
Can you post the exact error message you get without your patch?
Indeed, converting it to int() seems to be better. I thought of delta=0.5 because when it exceeds 0.5 it should roll over hdr.mtime. This is the error:
Traceback (most recent call last):
File "/home/bogdano/git/osc2/test/util/test_cpio.py", line 608, in test18
self.assertEqual(float(hdr.mtime), st.st_mtime)
AssertionError: 1362500288.0 != 1362500288.444055
Fixed in commit d2b2e3aca7236305a791eac4ed8841d3fc7ffcaa. Thanks for the report!
posix.stat_result has a higher precision than AsciiReader header's, resulting in a test failling because of a difference smaller than 0.5 second.