File: test_benchmark.py

package info (click to toggle)
filetype.py 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,560 kB
  • sloc: python: 1,841; makefile: 42; sh: 21
file content (41 lines) | stat: -rw-r--r-- 998 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# -*- coding: utf-8 -*-

from __future__ import absolute_import

import os

import filetype

# Absolute path to fixtures directory
FIXTURES = os.path.dirname(os.path.abspath(__file__)) + '/fixtures'


def test_infer_image_from_disk(benchmark):
    benchmark(filetype.guess, FIXTURES + '/sample.jpg')


def test_infer_video_from_disk(benchmark):
    benchmark(filetype.guess, FIXTURES + '/sample.mp4')


def test_infer_zip_from_disk(benchmark):
    benchmark(filetype.guess, FIXTURES + '/sample.zip')


def test_infer_tar_from_disk(benchmark):
    benchmark(filetype.guess, FIXTURES + '/sample.tar')


def test_infer_image_from_bytes(benchmark):
    benchmark(filetype.guess,
              bytearray([0xFF, 0xD8, 0xFF, 0x00, 0x08]))


def test_infer_video_from_bytes(benchmark):
    benchmark(filetype.guess,
              bytearray([0x1A, 0x45, 0xDF, 0xA3, 0x08]))


def test_infer_audio_from_bytes(benchmark):
    benchmark(filetype.guess,
              bytearray([0x4D, 0x54, 0x68, 0xA3, 0x64]))