forked from BoboTiG/python-mss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_save.py
More file actions
52 lines (36 loc) · 1.35 KB
/
test_save.py
File metadata and controls
52 lines (36 loc) · 1.35 KB
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
48
49
50
51
52
# coding: utf-8
import os.path
from datetime import datetime
def test_at_least_2_monitors(sct):
shots = list(sct.save(mon=0))
assert len(shots) >= 1
def test_files_exist(sct):
for filename in sct.save():
assert os.path.isfile(filename)
assert os.path.isfile(sct.shot())
sct.shot(mon=-1, output="fullscreen.png")
assert os.path.isfile("fullscreen.png")
def test_callback(sct):
def on_exists(fname):
if os.path.isfile(fname):
new_file = fname + ".old"
os.rename(fname, new_file)
filename = sct.shot(mon=0, output="mon0.png", callback=on_exists)
assert os.path.isfile(filename)
filename = sct.shot(output="mon1.png", callback=on_exists)
assert os.path.isfile(filename)
def test_output_format(sct):
filename = sct.shot(mon=1, output="mon-{mon}.png")
assert filename == "mon-1.png"
assert os.path.isfile(filename)
fmt = "sct-{top}x{left}_{width}x{height}.png"
filename = sct.shot(mon=1, output=fmt)
assert filename == fmt.format(**sct.monitors[1])
assert os.path.isfile(filename)
fmt = "sct_{mon}-{date}.png"
filename = sct.shot(mon=1, output=fmt)
assert os.path.isfile(filename)
fmt = "sct_{date:%Y-%m-%d}.png"
filename = sct.shot(mon=1, output=fmt)
assert filename == fmt.format(date=datetime.now())
assert os.path.isfile(filename)