

def test_lazy_import(self):
    '\n        Test the lazy packet parsing against the regular implementation.\n        '
    tfile = create_pcap()
    capfile_gen = savefile.load_savefile(tfile, lazy=True)
    packets = list(capfile_gen.packets)
    tfile.close()
    if os.path.exists(tfile.name):
        os.unlink(self.name)
    self.assertEqual(len(packets), len(self.capfile.packets), 'lazy parsing gives different number of packets!')
    fields = ['timestamp', 'timestamp_ms', 'capture_len', 'packet_len', 'packet']
    for (act, ref) in zip(packets, capfile_gen.packets):
        for field in fields:
            self.assertEqual(getattr(act, field), getattr(ref, field), 'lazy parsing gives different data!')

dataset/ETHPy150Open kisom/pypcapfile/pcapfile/test/savefile_test.py TestCase.test_lazy_import/VarMisuse@64/106 `tfile`->`self`