本文整理匯總了Python中olympia.files.helpers.FileViewer.is_extracted方法的典型用法代碼示例。如果您正苦於以下問題:Python FileViewer.is_extracted方法的具體用法?Python FileViewer.is_extracted怎麽用?Python FileViewer.is_extracted使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類olympia.files.helpers.FileViewer
的用法示例。
在下文中一共展示了FileViewer.is_extracted方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestFileHelper
# 需要導入模塊: from olympia.files.helpers import FileViewer [as 別名]
# 或者: from olympia.files.helpers.FileViewer import is_extracted [as 別名]
class TestFileHelper(TestCase):
def setUp(self):
super(TestFileHelper, self).setUp()
self.viewer = FileViewer(make_file(1, get_file('dictionary-test.xpi')))
def tearDown(self):
self.viewer.cleanup()
super(TestFileHelper, self).tearDown()
def test_files_not_extracted(self):
assert not self.viewer.is_extracted()
def test_files_extracted(self):
self.viewer.extract()
assert self.viewer.is_extracted()
def test_recurse_extract(self):
self.viewer.src = get_file('recurse.xpi')
self.viewer.extract()
assert self.viewer.is_extracted()
def test_recurse_contents(self):
self.viewer.src = get_file('recurse.xpi')
self.viewer.extract()
files = self.viewer.get_files()
file_list = [
'recurse/recurse.xpi/chrome/test-root.txt',
'recurse/somejar.jar/recurse/recurse.xpi/chrome/test.jar',
'recurse/somejar.jar/recurse/recurse.xpi/chrome/test.jar/test'
]
for name in file_list:
assert name in files
def test_recurse_contents_of_zip(self):
self.viewer.src = get_file('recurse.zip')
self.viewer.extract()
files = self.viewer.get_files()
file_list = [
'recurse/recurse.xpi/chrome/test-root.txt',
'recurse/somejar.jar/recurse/recurse.xpi/chrome/test.jar',
'recurse/somejar.jar/recurse/recurse.xpi/chrome/test.jar/test'
]
for name in file_list:
assert name in files
def test_cleanup(self):
self.viewer.extract()
self.viewer.cleanup()
assert not self.viewer.is_extracted()
def test_isbinary(self):
binary = self.viewer._is_binary
for f in ['foo.rdf', 'foo.xml', 'foo.js', 'foo.py'
'foo.html', 'foo.txt', 'foo.dtd', 'foo.xul', 'foo.sh',
'foo.properties', 'foo.json', 'foo.src', 'CHANGELOG']:
m, encoding = mimetypes.guess_type(f)
assert not binary(m, f), '%s should not be binary' % f
for f in ['foo.png', 'foo.gif', 'foo.exe', 'foo.swf']:
m, encoding = mimetypes.guess_type(f)
assert binary(m, f), '%s should be binary' % f
filename = os.path.join(settings.TMP_PATH, 'test_isbinary')
for txt in ['#!/usr/bin/python', '#python', u'\0x2']:
open(filename, 'w').write(txt)
m, encoding = mimetypes.guess_type(filename)
assert not binary(m, filename), '%s should not be binary' % txt
for txt in ['MZ']:
open(filename, 'w').write(txt)
m, encoding = mimetypes.guess_type(filename)
assert binary(m, filename), '%s should be binary' % txt
os.remove(filename)
def test_truncate(self):
truncate = self.viewer.truncate
for x, y in (['foo.rdf', 'foo.rdf'],
['somelongfilename.rdf', 'somelongfilenam...rdf'],
[u'unicode삮.txt', u'unicode\uc0ae.txt'],
[u'unicodesomelong삮.txt', u'unicodesomelong...txt'],
['somelongfilename.somelongextension',
'somelongfilenam...somelonge..'],):
assert truncate(x) == y
def test_get_files_not_extracted(self):
assert not self.viewer.get_files()
def test_get_files_size(self):
self.viewer.extract()
files = self.viewer.get_files()
assert len(files) == 14
def test_get_files_directory(self):
self.viewer.extract()
files = self.viewer.get_files()
assert not files['install.js']['directory']
assert not files['install.js']['binary']
assert files['__MACOSX']['directory']
assert not files['__MACOSX']['binary']
#.........這裏部分代碼省略.........