def testDumpGzippedAndLoadBloomFilter(self): bloom_filter = BloomFilter(self.BLOOM_CAPACITY, self.BLOOM_ERROR_RATE) for key in self.all_keys: bloom_filter.add(key) dump_bytes = bloom_filter.dump(gzipped=True); bloom_filter2 = BloomFilter.load(dump_bytes) self.assertEqual(bloom_filter, bloom_filter2) self.check_contains(bloom_filter2)
def testLoadBloomFilterFromFile(self): with open(self.BF_DUMP_FILE, "rb") as f: dump_bytes = f.read() bloom_filter = BloomFilter.load(dump_bytes) self.check_contains(bloom_filter)