01_less_strict_index_tests 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Description: Make index entry tests a little bit less strict, to cope with
  2. slightly different behaviour on various platforms.
  3. Origin: commit, revision id: git-v1:c398d692d1ba6c5fcee26383bfc78f73875de20b
  4. Author: Jelmer Vernooij <jelmer@samba.org>
  5. Last-Update: 2012-04-02
  6. Applied-Upstream: merged in revision 1044
  7. X-Bzr-Revision-Id: git-v1:c398d692d1ba6c5fcee26383bfc78f73875de20b
  8. === modified file 'dulwich/tests/test_index.py'
  9. --- old/dulwich/tests/test_index.py 2012-04-02 10:29:11 +0000
  10. +++ new/dulwich/tests/test_index.py 2012-04-02 10:37:42 +0000
  11. @@ -26,7 +26,6 @@
  12. import shutil
  13. import stat
  14. import struct
  15. -import sys
  16. import tempfile
  17. from dulwich.index import (
  18. @@ -216,11 +215,7 @@
  19. class BuildIndexTests(TestCase):
  20. - def assertReasonableIndexEntry(self, index_entry,
  21. - time, mode, filesize, sha):
  22. - delta = 1000000
  23. - self.assertEquals(index_entry[0], index_entry[1]) # ctime and atime
  24. - self.assertTrue(index_entry[0] > time - delta)
  25. + def assertReasonableIndexEntry(self, index_entry, mode, filesize, sha):
  26. self.assertEquals(index_entry[4], mode) # mode
  27. self.assertEquals(index_entry[7], filesize) # filesize
  28. self.assertEquals(index_entry[8], sha) # sha
  29. @@ -280,8 +275,6 @@
  30. repo.object_store, tree.id)
  31. # Verify index entries
  32. - import time
  33. - ctime = time.time()
  34. index = repo.open_index()
  35. self.assertEquals(len(index), 4)
  36. @@ -289,28 +282,28 @@
  37. apath = os.path.join(repo.path, 'a')
  38. self.assertTrue(os.path.exists(apath))
  39. self.assertReasonableIndexEntry(index['a'],
  40. - ctime, stat.S_IFREG | 0644, 6, filea.id)
  41. + stat.S_IFREG | 0644, 6, filea.id)
  42. self.assertFileContents(apath, 'file a')
  43. # fileb
  44. bpath = os.path.join(repo.path, 'b')
  45. self.assertTrue(os.path.exists(bpath))
  46. self.assertReasonableIndexEntry(index['b'],
  47. - ctime, stat.S_IFREG | 0644, 6, fileb.id)
  48. + stat.S_IFREG | 0644, 6, fileb.id)
  49. self.assertFileContents(bpath, 'file b')
  50. # filed
  51. dpath = os.path.join(repo.path, 'c', 'd')
  52. self.assertTrue(os.path.exists(dpath))
  53. self.assertReasonableIndexEntry(index['c/d'],
  54. - ctime, stat.S_IFREG | 0644, 6, filed.id)
  55. + stat.S_IFREG | 0644, 6, filed.id)
  56. self.assertFileContents(dpath, 'file d')
  57. # symlink to d
  58. epath = os.path.join(repo.path, 'c', 'e')
  59. self.assertTrue(os.path.exists(epath))
  60. self.assertReasonableIndexEntry(index['c/e'],
  61. - ctime, stat.S_IFLNK, 1, filee.id)
  62. + stat.S_IFLNK, 1, filee.id)
  63. self.assertFileContents(epath, 'd', symlink=True)
  64. # Verify no extra files