本文整理汇总了Python中tests.fetch_file函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_file函数的具体用法?Python fetch_file怎么用?Python fetch_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fetch_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_color_info_line_drawings
def test_color_info_line_drawings(self):
data = ImageFile(fetch_file(
'simple_line_drawing.jpg')).analyze_color_info()
self.assertIn('Color:AverageRGB', data)
self.assertEqual(data['Color:AverageRGB'], (243.131, 243.131, 243.131))
self.assertEqual(data['Color:NumberOfGreyShades'], 5)
self.assertEqual(round(data['Color:PercentFrequentColors'], 3), 0.016)
self.assertEqual(round(data['Color:EdgeRatio'], 3), 0.191)
data = ImageFile(fetch_file(
'detailed_line_drawing.jpg')).analyze_color_info()
self.assertIn('Color:AverageRGB', data)
self.assertEqual(data['Color:AverageRGB'], (229.461, 229.461, 229.461))
self.assertEqual(data['Color:NumberOfGreyShades'], 1)
self.assertEqual(round(data['Color:PercentFrequentColors'], 3), 0.004)
self.assertEqual(round(data['Color:EdgeRatio'], 3), 0.112)
data = ImageFile(fetch_file(
'very_detailed_line_drawing.jpg')).analyze_color_info()
self.assertIn('Color:AverageRGB', data)
self.assertEqual(data['Color:AverageRGB'], (135.896, 135.896, 135.896))
self.assertEqual(data['Color:NumberOfGreyShades'], 8)
self.assertEqual(round(data['Color:PercentFrequentColors'], 3), 0.012)
self.assertEqual(round(data['Color:EdgeRatio'], 3), 0.283)
data = ImageFile(fetch_file(
'dark_line_drawing.jpg')).analyze_color_info()
self.assertIn('Color:AverageRGB', data)
self.assertEqual(data['Color:AverageRGB'], (204.207, 204.207, 204.207))
self.assertEqual(data['Color:NumberOfGreyShades'], 2)
self.assertEqual(round(data['Color:PercentFrequentColors'], 3), 0.008)
self.assertEqual(round(data['Color:EdgeRatio'], 3), 0.093)
示例2: test_create_svg_file
def test_create_svg_file(self):
from file_metadata.image.svg_file import SVGFile
for fname in ['text_html.svg', 'text_plain.svg', 'image_svg_xml.svg',
'application_xml.svg']:
self.assertTrue(isinstance(
GenericFile.create(fetch_file(fname)), SVGFile),
'File "{0}" was not of type {1}'.format(fname, SVGFile))
示例3: test_exiftool_encoding
def test_exiftool_encoding(self):
_file = GenericFile(fetch_file('nonascii_exifdata.jpg'))
# Test with a file that has non-ascii characters in the exif
# information
data = _file.analyze_exifdata()
self.assertEqual(data['XMP:State'], 'Franche-Comté')
self.assertIn('Éclipse', data['XMP:Description'])
示例4: test_create_audio_file
def test_create_audio_file(self):
from file_metadata.audio.audio_file import AudioFile
for fname in ['drums.mid', 'bell.flac', 'bell.wav', 'bell.ogg',
'bell.oga']:
self.assertTrue(isinstance(
GenericFile.create(fetch_file(fname)), AudioFile),
'File "{0}" was not of type {1}'.format(fname, AudioFile))
示例5: test_create_application_file
def test_create_application_file(self):
from file_metadata.application.application_file import ApplicationFile
for fname in ['image.pdf', 'text.pdf', 'empty.djvu']:
self.assertTrue(isinstance(
ApplicationFile.create(fetch_file(fname)), ApplicationFile),
'File "{0}" was not of type {1}'.format(fname,
ApplicationFile))
示例6: test_geolocation_nominatim_osaka
def test_geolocation_nominatim_osaka(self):
_file = ImageFile(fetch_file('geotag_osaka.jpg'))
data = _file.analyze_geolocation()
self.assertIn('Composite:GPSCountry', data)
self.assertEqual(data.get('Composite:GPSCountry'), 'Japan')
self.assertEqual(data.get('Composite:GPSState'), None)
self.assertEqual(data.get('Composite:GPSCity'), 'Moriguchi')
示例7: test_barcode_zxing_dmtx
def test_barcode_zxing_dmtx(self):
_file = ImageFile(fetch_file('datamatrix.png'))
data = _file.analyze_barcode_zxing()
self.assertIn('zxing:Barcodes', data)
self.assertEqual(len(data['zxing:Barcodes']), 1)
self.assertEqual(data['zxing:Barcodes'][0]['format'], 'DATA_MATRIX')
self.assertEqual(data['zxing:Barcodes'][0]['data'],
'Wikipedia, the free encyclopedia')
示例8: test_exiftool_binary
def test_exiftool_binary(self):
_file = GenericFile(fetch_file('file.bin'))
data = _file.analyze_exifdata()
self.assertTrue(data['File:FileSize'], '256 bytes')
# The `exiftool` property should have all the info, but the
# analyze method should not.
self.assertNotIn('ExifTool:Error', data)
self.assertIn('ExifTool:Error', _file.exiftool())
示例9: test_geolocation_osaka
def test_geolocation_osaka(self):
_file = ImageFile(fetch_file('geotag_osaka.jpg'))
data = _file.analyze_geolocation(use_nominatim=False)
self.assertIn('Composite:GPSLatitude', data)
self.assertEqual(int(data.get('Composite:GPSLatitude', 0) * 1e6),
34748261)
self.assertEqual(int(data.get('Composite:GPSLongitude', 0) * 1e6),
135576661)
示例10: test_barcode_zxing_barcode
def test_barcode_zxing_barcode(self):
_file = ImageFile(fetch_file('barcode.png'))
data = _file.analyze_barcode_zxing()
self.assertIn('zxing:Barcodes', data)
self.assertEqual(len(data['zxing:Barcodes']), 1)
self.assertEqual(data['zxing:Barcodes'][0]['format'], 'CODABAR')
self.assertEqual(data['zxing:Barcodes'][0]['data'], '137255')
self.assertEqual(data['zxing:Barcodes'][0]['bounding box'],
{'width': 100, 'top': 29, 'height': 1, 'left': 4})
示例11: test_face_haarcascade_baby_face
def test_face_haarcascade_baby_face(self):
_file = ImageFile(fetch_file('baby_face.jpg'))
data = _file.analyze_face_haarcascades()
self.assertIn('OpenCV:Faces', data)
self.assertEqual(len(data['OpenCV:Faces']), 1)
face = data['OpenCV:Faces'][0]
self.assertEqual(face['mouth'], (851, 1381))
self.assertIn('position', face)
示例12: test_face_haarcascade_mona_lisa
def test_face_haarcascade_mona_lisa(self):
with ImageFile(fetch_file('mona_lisa.jpg')) as uut:
data = uut.analyze_face_haarcascades()
self.assertIn('OpenCV:Faces', data)
self.assertEqual(len(data['OpenCV:Faces']), 1)
face = data['OpenCV:Faces'][0]
self.assertEqual(face['nose'], (318, 310))
self.assertEqual(face['mouth'], (325, 341))
示例13: test_face_haarcascade_charlie_chaplin
def test_face_haarcascade_charlie_chaplin(self):
with ImageFile(fetch_file('charlie_chaplin.jpg')) as uut:
data = uut.analyze_face_haarcascades()
self.assertIn('OpenCV:Faces', data)
self.assertEqual(len(data['OpenCV:Faces']), 1)
face = data['OpenCV:Faces'][0]
self.assertEqual(face['nose'], (776, 688))
self.assertEqual(face['mouth'], (735, 794))
示例14: test_file_close
def test_file_close(self):
uut = GenericFile(fetch_file('ascii.txt'))
fd, name = tempfile.mkstemp(
suffix=os.path.split(uut.fetch('filename'))[-1] + '.png')
os.close(fd)
uut.temp_filenames.add(name)
self.assertTrue(os.path.exists(name))
uut.close()
self.assertFalse(os.path.exists(name))
示例15: test_xcf_fetch_filename_raster
def test_xcf_fetch_filename_raster(self):
_file = XCFFile(fetch_file('blank.xcf'))
self.assertTrue(_file.fetch('filename_raster').endswith('.png'))
self.assertEqual(len(_file.temp_filenames), 1)
name = tuple(_file.temp_filenames)[0]
self.assertTrue(os.path.exists(name))
_file.close()
self.assertFalse(os.path.exists(name))