136
136
compressor.compress(('label3',),
137
137
['new\n', 'common\n', 'different\n', 'moredifferent\n'], None)
138
138
self.assertAlmostEqual(0.3, compressor.ratio(), 1)
140
def test_extract_from_compressor(self):
141
# Knit fetching will try to reconstruct texts locally which results in
142
# reading something that is in the compressor stream already.
143
compressor = groupcompress.GroupCompressor(True)
144
sha_1, _ = compressor.compress(('label',),
145
['strange\n', 'common\n'], None)
146
sha_2, _ = compressor.compress(('newlabel',),
147
['common\n', 'different\n', 'moredifferent\n'], None)
149
self.assertEqual((['strange\n', 'common\n'], sha_1),
150
compressor.extract(('label',)))
152
self.assertEqual((['common\n', 'different\n', 'moredifferent\n'],
153
sha_2), compressor.extract(('newlabel',)))