def test_countfiles(self): Extractor.open('data/100_files.zip').countfiles(10) Extractor.open('data/100_files.zip').countfiles(200) Extractor.open('data/dir_in_dir.rar').countfiles(200)
def test_onedir(self): Extractor.open('data/100_files.zip').onedir() Extractor.open('data/mac_one_dir.zip').onedir()
def test_unrecognized_singal_file(self): with self.assertRaises(ValueError): Extractor.open('data/single_file2.zjq')
def test_extract_rar_files(self): files = list(Extractor.open('data/dir_in_dir.rar').extract()) files = list(Extractor.open('data/single_file.rar').extract()) self.assertEqual(len(files), 1) self.assertEqual(files[0][0], 't1.txt') self.assertEqual(files[0][1].read().strip(), 'this is t1')
def test_iteration(self): iter(Extractor.open('data/dir_in_dir.zip')) iter(Extractor.open('data/dir_in_dir.rar'))
def test_context_manager(self): ext = Extractor('data/single_file.zip') with ext.open('data/single_file.zip'): pass with Extractor(None): pass
def test_no_file(self): ext = Extractor('data/single_file.zip') with self.assertRaises(NotImplementedError): ext.extract() with self.assertRaises(NotImplementedError): ext.filelist()