Skip to content

Commit 2564372

Browse files
committed
tests: first version for Travis testing (fix BoboTiG#9)
1 parent 2b31760 commit 2564372

3 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎tests/conftest.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
from os import environ
5+
6+
import pytest
7+
8+
from mss import mss as MSS
9+
10+
11+
def pytest_addoption(parser):
12+
txt = 'Display to use (examples: ":0.1", ":0" [default])'
13+
parser.addoption('--display', action='store', default=':0', help=txt)
14+
15+
16+
@pytest.fixture(scope='session')
17+
def display(request):
18+
return request.config.getoption('--display')
19+
20+
21+
@pytest.fixture(scope='module')
22+
def mss(display):
23+
try:
24+
# display keyword is only for GNU/Linux
25+
return MSS(display=display)
26+
except TypeError:
27+
return MSS()
28+
29+
30+
@pytest.fixture(scope='session')
31+
def is_travis():
32+
return 'TRAVIS' in environ

‎tests/test_attributes.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
5+
def test_attribute_image(mss):
6+
assert mss.image is None
7+
8+
9+
def test_attribute_monitors(mss):
10+
assert mss.monitors == []
11+
12+
13+
def test_attribute_width(mss):
14+
assert mss.width == 0
15+
16+
17+
def test_attribute_height(mss):
18+
assert mss.height == 0
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python
2+
# coding: utf-8
3+
4+
5+
def test_get_monitors(mss):
6+
monitors = mss.enum_display_monitors()
7+
assert monitors is mss.monitors
8+
assert monitors
9+
10+
11+
def test_keys_aio(mss):
12+
all_monitors = mss.monitors[0]
13+
assert 'top' in all_monitors
14+
assert 'left' in all_monitors
15+
assert 'height' in all_monitors
16+
assert 'width' in all_monitors
17+
18+
19+
def test_keys_monitor_1(mss):
20+
mon1 = mss.monitors[1]
21+
assert 'top' in mon1
22+
assert 'left' in mon1
23+
assert 'height' in mon1
24+
assert 'width' in mon1
25+
26+
27+
def test_dimensions(mss, is_travis):
28+
width = 1280 if is_travis else 0
29+
height = 1024 if is_travis else 0
30+
for mon in mss.monitors:
31+
assert mon['width'] >= width
32+
assert mon['height'] >= height
33+
34+
35+
def test_get_monitors_force(mss):
36+
monitors = mss.enum_display_monitors(force=True)
37+
assert monitors is mss.monitors
38+
assert monitors

0 commit comments

Comments
 (0)