Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48a88f3

Browse files
committed
Tests: add bgra_to_rgb()
1 parent 977f486 commit 48a88f3

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ def sct(display):
3030
@pytest.fixture(scope='session')
3131
def is_travis():
3232
return 'TRAVIS' in environ
33+
34+
35+
@pytest.fixture(scope='session')
36+
def raw():
37+
return open('tests/monitor-1024x768.raw', 'rb').read()

tests/monitor-1024x768.raw

3 MB
Binary file not shown.

tests/test_bgra_to_rgb.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
import pytest
5+
6+
7+
def test_bad_length(sct):
8+
sct.width = 1024
9+
sct.height = 768
10+
with pytest.raises(ValueError):
11+
sct.bgra_to_rgb(bytearray(b'789c626001000000ffff030000060005'))
12+
13+
14+
def test_good_bytes(sct, raw):
15+
sct.width = 1024
16+
sct.height = 768
17+
image = sct.bgra_to_rgb(raw)
18+
assert isinstance(image, bytes)
19+
20+
21+
def test_good_bytearray(sct, raw):
22+
sct.width = 1024
23+
sct.height = 768
24+
image = sct.bgra_to_rgb(bytearray(raw))
25+
assert isinstance(image, bytes)

0 commit comments

Comments
 (0)