• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tests.fetch_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.fetch_file函数的典型用法代码示例。如果您正苦于以下问题:Python fetch_file函数的具体用法?Python fetch_file怎么用?Python fetch_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fetch_file函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:32,代码来源:image_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:7,代码来源:generic_file_test.py


示例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'])
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:7,代码来源:generic_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:7,代码来源:generic_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:7,代码来源:generic_file_test.py


示例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')
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:7,代码来源:image_file_test.py


示例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')
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:8,代码来源:image_file_test.py


示例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())
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:8,代码来源:generic_file_test.py


示例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)
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:8,代码来源:image_file_test.py


示例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})
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:image_file_test.py


示例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)
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:image_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:image_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:image_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:generic_file_test.py


示例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))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:xcf_file_test.py


示例16: test_filename_zxing

    def test_filename_zxing(self):
        uut = TIFFFile(fetch_file('example.tiff'))
        self.assertIn('tmp_file_metadata', uut.fetch('filename_zxing'))

        self.assertEqual(len(uut.temp_filenames), 1)
        name = tuple(uut.temp_filenames)[0]
        self.assertTrue(os.path.exists(name))
        uut.close()
        self.assertFalse(os.path.exists(name))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:tiff_file_test.py


示例17: test_svg_fetch_filename_raster

    def test_svg_fetch_filename_raster(self):
        uut = SVGFile(fetch_file('image_svg_xml.svg'))
        self.assertTrue(uut.fetch('filename_raster').endswith('.png'))

        self.assertEqual(len(uut.temp_filenames), 1)
        name = tuple(uut.temp_filenames)[0]
        self.assertTrue(os.path.exists(name))
        uut.close()
        self.assertFalse(os.path.exists(name))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:svg_file_test.py


示例18: test_enter_exit

 def test_enter_exit(self):
     name = None
     with GenericFile(fetch_file('ascii.txt')) as uut:
         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))
     self.assertFalse(os.path.exists(name))
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:9,代码来源:generic_file_test.py


示例19: test_barcode_zxing_multiple_barcodes

 def test_barcode_zxing_multiple_barcodes(self):
     _file = ImageFile(fetch_file('multibarcodes.png'))
     data = _file.analyze_barcode_zxing()
     self.assertIn('zxing:Barcodes', data)
     self.assertEqual(len(data['zxing:Barcodes']), 2)
     self.assertEqual(data['zxing:Barcodes'][0]['format'], 'CODE_128')
     self.assertEqual(data['zxing:Barcodes'][0]['data'],
                      '2LUS94941+67000000')
     self.assertEqual(data['zxing:Barcodes'][1]['format'], 'ITF')
     self.assertEqual(data['zxing:Barcodes'][1]['data'], '054804124097')
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:10,代码来源:image_file_test.py


示例20: test_color_info_animated_image

 def test_color_info_animated_image(self):
     data = ImageFile(fetch_file('animated.gif')).analyze_color_info()
     self.assertIn('Color:AverageRGB', data)
     self.assertEqual(data['Color:AverageRGB'], (227.326, 224.414, 224.414))
     self.assertEqual(data['Color:ClosestLabeledColor'],
                      'PMS 13-4108 TPX (Nimbus Cloud)')
     self.assertEqual(data['Color:ClosestLabeledColorRGB'], (223, 223, 227))
     self.assertEqual(round(data['Color:PercentFrequentColors'], 3), 0.008)
     self.assertNotIn('Color:EdgeRatio', data)
     self.assertNotIn('Color:NumberOfGreyShades', data)
开发者ID:pywikibot-catfiles,项目名称:file-metadata,代码行数:10,代码来源:image_file_test.py



注:本文中的tests.fetch_file函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.get_config函数代码示例发布时间:2022-05-27
下一篇:
Python tests.expect函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap