-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathtest_benchmark.py
More file actions
32 lines (24 loc) · 935 Bytes
/
Copy pathtest_benchmark.py
File metadata and controls
32 lines (24 loc) · 935 Bytes
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
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import os
import filetype
import pytest
from . import FIXTURES
@pytest.mark.parametrize('filename',
[
'sample.jpg',
'sample.mp4',
'sample.zip',
'sample.tar',
])
def test_infer_from_disk(benchmark, filename):
benchmark(filetype.guess, os.path.join(FIXTURES, filename))
@pytest.mark.parametrize('bytes_',
[
[0xFF, 0xD8, 0xFF, 0x00, 0x08],
[0x1A, 0x45, 0xDF, 0xA3, 0x08],
[0x4D, 0x54, 0x68, 0xA3, 0x64],
],
ids=['image', 'video', 'audio'])
def test_infer_from_bytes(benchmark, bytes_):
benchmark(filetype.guess, bytearray(bytes_))