~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

Merge bzr.dev 4187, and revert the change to fix refcycle issues.

I apparently didn't run the smart fetch tests. Which show that we access inv+chk pages
as a fulltext, and then insert the stream, which expects to get the block as a compressed
block. :(.
Need to rethink how to do it, possibly with weakrefs.


This also brings in CommitBuilder.record_iter_changes() and the updates to btree_index
and backing indices.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1475
1475
        self.assertTrue(-eighteen_hours < offset < eighteen_hours)
1476
1476
 
1477
1477
 
 
1478
class TestSizeShaFile(TestCaseInTempDir):
 
1479
 
 
1480
    def test_sha_empty(self):
 
1481
        self.build_tree_contents([('foo', '')])
 
1482
        expected_sha = osutils.sha_string('')
 
1483
        f = open('foo')
 
1484
        self.addCleanup(f.close)
 
1485
        size, sha = osutils.size_sha_file(f)
 
1486
        self.assertEqual(0, size)
 
1487
        self.assertEqual(expected_sha, sha)
 
1488
 
 
1489
    def test_sha_mixed_endings(self):
 
1490
        text = 'test\r\nwith\nall\rpossible line endings\r\n'
 
1491
        self.build_tree_contents([('foo', text)])
 
1492
        expected_sha = osutils.sha_string(text)
 
1493
        f = open('foo')
 
1494
        self.addCleanup(f.close)
 
1495
        size, sha = osutils.size_sha_file(f)
 
1496
        self.assertEqual(38, size)
 
1497
        self.assertEqual(expected_sha, sha)
 
1498
 
 
1499
 
1478
1500
class TestShaFileByName(TestCaseInTempDir):
1479
1501
 
1480
1502
    def test_sha_empty(self):