forked from python-openxml/python-docx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bmp.py
More file actions
48 lines (35 loc) · 1.38 KB
/
test_bmp.py
File metadata and controls
48 lines (35 loc) · 1.38 KB
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
42
43
44
45
46
47
48
# encoding: utf-8
"""
Test suite for docx.image.bmp module
"""
from __future__ import absolute_import, print_function
import pytest
from docx.compat import BytesIO
from docx.image.constants import MIME_TYPE
from docx.image.bmp import Bmp
from ..unitutil.mock import initializer_mock
class DescribeBmp(object):
def it_can_construct_from_a_bmp_stream(self, from_stream_fixture):
stream, Bmp__init__, cx, cy, horz_dpi, vert_dpi = from_stream_fixture
bmp = Bmp.from_stream(stream)
Bmp__init__.assert_called_once_with(cx, cy, horz_dpi, vert_dpi)
assert isinstance(bmp, Bmp)
def it_knows_its_content_type(self):
bmp = Bmp(None, None, None, None)
assert bmp.content_type == MIME_TYPE.BMP
def it_knows_its_default_ext(self):
bmp = Bmp(None, None, None, None)
assert bmp.default_ext == 'bmp'
# fixtures -------------------------------------------------------
@pytest.fixture
def from_stream_fixture(self, Bmp__init__):
cx, cy, horz_dpi, vert_dpi = 26, 43, 200, 96
bytes_ = (
b'fillerfillerfiller\x1A\x00\x00\x00\x2B\x00\x00\x00'
b'fillerfiller\xB8\x1E\x00\x00\x00\x00\x00\x00'
)
stream = BytesIO(bytes_)
return stream, Bmp__init__, cx, cy, horz_dpi, vert_dpi
@pytest.fixture
def Bmp__init__(self, request):
return initializer_mock(request, Bmp)