forked from BoboTiG/python-mss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
47 lines (33 loc) · 982 Bytes
/
conftest.py
File metadata and controls
47 lines (33 loc) · 982 Bytes
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
"""
This is part of the MSS Python's module.
Source: https://github.com/BoboTiG/python-mss
"""
import glob
import os
import mss
import pytest
def purge_files():
""" Remove all generated files from previous runs. """
for fname in glob.glob("*.png"):
print("Deleting {!r} ...".format(fname))
os.unlink(fname)
for fname in glob.glob("*.png.old"):
print("Deleting {!r} ...".format(fname))
os.unlink(fname)
@pytest.fixture(scope="module", autouse=True)
def before_tests(request):
request.addfinalizer(purge_files)
@pytest.fixture(scope="module")
def sct():
try:
# `display` kwarg is only for GNU/Linux
return mss.mss(display=os.getenv("DISPLAY"))
except TypeError:
return mss.mss()
@pytest.fixture(scope="session")
def is_travis():
return "TRAVIS" in os.environ
@pytest.fixture(scope="session")
def raw():
with open("tests/res/monitor-1024x768.raw", "rb") as f:
yield f.read()