def test_zipfile(self): archive = open_archive(self.filename) content = archive.extractbytes('content') self.assertEqual(content, b'root file test') dst = os.path.join(self.tmp, 'dst') unpack_archive(archive, dst) subprocess.check_call(['diff', '-r', 'src', 'dst'], cwd=self.tmp)
def run(): parser = make_parser() args = parser.parse_args(sys.argv[1:]) filename = args.pkg[0] dirname = args.dir try: archive = open_archive(filename) except ValueError: print('Error: Unknown file type: {}'.format(filename), file=sys.stderr) return 1 if args.file: contents = archive.extractbytes(args.file) if contents: print(contents, end='') return 0 else: return 1 if dirname and os.path.exists(dirname): print('Error: Directory {} already exists'.format(dirname), file=sys.stderr) return 1 unpack_archive(archive, dirname) return 0
def test_zipfile(self): archive = open_archive(self.filename) content = archive.extractbytes('content') self.assertEqual(content, b'root file test') dst = os.path.join(self.tmp, 'dst') unpack_archive(archive, dst) subprocess.check_call([ 'diff', '-r', 'src', 'dst' ], cwd=self.tmp)