1010
1111from docx .compat import BytesIO
1212from docx .image .exceptions import UnexpectedEndOfFileError
13- from docx .image .helpers import BIG_ENDIAN , StreamReader
13+ from docx .image .helpers import BIG_ENDIAN , LITTLE_ENDIAN , StreamReader
1414
1515
1616class DescribeStreamReader (object ):
@@ -26,8 +26,23 @@ def it_raises_on_unexpected_EOF(self, read_str_fixture):
2626 with pytest .raises (UnexpectedEndOfFileError ):
2727 stream_rdr .read_str (9 , 2 )
2828
29+ def it_can_read_a_long (self , read_long_fixture ):
30+ stream_rdr , offset , expected_int = read_long_fixture
31+ l = stream_rdr .read_long (offset )
32+ assert l == expected_int
33+
2934 # fixtures -------------------------------------------------------
3035
36+ @pytest .fixture (params = [
37+ (BIG_ENDIAN , b'\xBE \x00 \x00 \x00 \x2A \xEF ' , 1 , 42 ),
38+ (LITTLE_ENDIAN , b'\xBE \xEF \x2A \x00 \x00 \x00 ' , 2 , 42 ),
39+ ])
40+ def read_long_fixture (self , request ):
41+ byte_order , bytes_ , offset , expected_int = request .param
42+ stream = BytesIO (bytes_ )
43+ stream_rdr = StreamReader (stream , byte_order )
44+ return stream_rdr , offset , expected_int
45+
3146 @pytest .fixture
3247 def read_str_fixture (self ):
3348 stream = BytesIO (b'\x01 \x02 foobar\x03 \x04 ' )
0 commit comments