Skip to content

Commit a5c457d

Browse files
committed
Tests: rename mss to sct to fit the documentation, and add on test for save()
1 parent 2722519 commit a5c457d

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77

8-
from mss import mss as MSS
8+
from mss import mss
99

1010

1111
def pytest_addoption(parser):
@@ -19,12 +19,12 @@ def display(request):
1919

2020

2121
@pytest.fixture(scope='module')
22-
def mss(display):
22+
def sct(display):
2323
try:
2424
# display keyword is only for GNU/Linux
25-
return MSS(display=display)
25+
return mss(display=display)
2626
except TypeError:
27-
return MSS()
27+
return mss()
2828

2929

3030
@pytest.fixture(scope='session')

tests/test_attributes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# coding: utf-8
33

44

5-
def test_attribute_image(mss):
6-
assert mss.image is None
5+
def test_attribute_image(sct):
6+
assert sct.image is None
77

88

9-
def test_attribute_monitors(mss):
10-
assert mss.monitors == []
9+
def test_attribute_monitors(sct):
10+
assert sct.monitors == []
1111

1212

13-
def test_attribute_width(mss):
14-
assert mss.width == 0
13+
def test_attribute_width(sct):
14+
assert sct.width == 0
1515

1616

17-
def test_attribute_height(mss):
18-
assert mss.height == 0
17+
def test_attribute_height(sct):
18+
assert sct.height == 0

tests/test_enum_display_monitors.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22
# coding: utf-8
33

44

5-
def test_get_monitors(mss):
6-
monitors = mss.enum_display_monitors()
7-
assert monitors is mss.monitors
5+
def test_get_monitors(sct):
6+
monitors = sct.enum_display_monitors()
7+
assert monitors is sct.monitors
88
assert monitors
99

1010

11-
def test_get_monitors_force(mss):
12-
monitors = mss.enum_display_monitors(force=True)
13-
assert monitors is mss.monitors
11+
def test_get_monitors_force(sct):
12+
monitors = sct.enum_display_monitors(force=True)
13+
assert monitors is sct.monitors
1414
assert monitors
1515

1616

17-
def test_keys_aio(mss):
18-
all_monitors = mss.monitors[0]
17+
def test_keys_aio(sct):
18+
all_monitors = sct.monitors[0]
1919
assert 'top' in all_monitors
2020
assert 'left' in all_monitors
2121
assert 'height' in all_monitors
2222
assert 'width' in all_monitors
2323

2424

25-
def test_keys_monitor_1(mss):
26-
mon1 = mss.monitors[1]
25+
def test_keys_monitor_1(sct):
26+
mon1 = sct.monitors[1]
2727
assert 'top' in mon1
2828
assert 'left' in mon1
2929
assert 'height' in mon1
3030
assert 'width' in mon1
3131

3232

33-
def test_dimensions(mss, is_travis):
34-
mon = mss.monitors[1]
33+
def test_dimensions(sct, is_travis):
34+
mon = sct.monitors[1]
3535
if not is_travis:
3636
assert mon['width'] > 0
3737
assert mon['height'] > 0
3838

3939

40-
def test_dimensions_travis(mss, is_travis):
41-
mon = mss.monitors[1]
40+
def test_dimensions_travis(sct, is_travis):
41+
mon = sct.monitors[1]
4242
if is_travis:
4343
assert mon['width'] == 1920
4444
assert mon['height'] == 1440

tests/test_get_pixels.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# coding: utf-8
33

44

5-
def test_get_pixels(mss):
6-
mon1 = mss.enum_display_monitors()[1]
7-
pixels = mss.get_pixels(mon1)
8-
assert pixels is mss.image
9-
assert isinstance(mss.image, bytes)
5+
def test_get_pixels(sct):
6+
mon1 = sct.enum_display_monitors()[1]
7+
pixels = sct.get_pixels(mon1)
8+
assert pixels is sct.image
9+
assert isinstance(sct.image, bytes)

tests/test_save.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/bin/env python
22
# coding: utf-8
33

4+
from os.path import isfile
45

5-
def test_at_least_2_monitors(mss):
6-
shots = list(mss.save(mon=0))
6+
7+
def test_at_least_2_monitors(sct):
8+
shots = list(sct.save(mon=0))
79
assert len(shots) >= 1
10+
11+
12+
def test_files_exist(sct):
13+
for filename in sct.save(mon=0):
14+
assert isfile(filename)

0 commit comments

Comments
 (0)