Skip to content

Commit c35bc06

Browse files
committed
tests: add --with-cursor entry point tests
1 parent dac8c57 commit c35bc06

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

mss/tests/test_implementation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,34 @@ def test_factory(monkeypatch):
7777
assert error == "System 'chuck norris' not (yet?) implemented."
7878

7979

80-
def test_entry_point(capsys):
80+
@pytest.mark.parametrize("with_cursor", [False, True])
81+
def test_entry_point(with_cursor: bool, capsys):
8182
from datetime import datetime
8283

83-
from mss.__main__ import main
84+
from mss.__main__ import main as entry_point
85+
86+
def main(*args):
87+
if with_cursor:
88+
args = args + ("--with-cursor",)
89+
entry_point(args)
8490

8591
for opt in ("-m", "--monitor"):
86-
main([opt, "1"])
92+
main(opt, "1")
8793
out, _ = capsys.readouterr()
8894
assert out.endswith("monitor-1.png\n")
8995
assert os.path.isfile("monitor-1.png")
9096
os.remove("monitor-1.png")
9197

92-
for opt in zip(("-m 1", "--monitor=1"), ("-q", "--quiet")):
93-
main(opt)
98+
for opt in zip(["-m 1", "--monitor=1"], ["-q", "--quiet"]):
99+
main(*opt)
94100
out, _ = capsys.readouterr()
95101
assert not out
96102
assert os.path.isfile("monitor-1.png")
97103
os.remove("monitor-1.png")
98104

99105
fmt = "sct-{mon}-{width}x{height}.png"
100106
for opt in ("-o", "--out"):
101-
main([opt, fmt])
107+
main(opt, fmt)
102108
out, _ = capsys.readouterr()
103109
with mss(display=os.getenv("DISPLAY")) as sct:
104110
for mon, (monitor, line) in enumerate(zip(sct.monitors[1:], out.splitlines()), 1):
@@ -109,7 +115,7 @@ def test_entry_point(capsys):
109115

110116
fmt = "sct_{mon}-{date:%Y-%m-%d}.png"
111117
for opt in ("-o", "--out"):
112-
main(["-m 1", opt, fmt])
118+
main("-m 1", opt, fmt)
113119
filename = fmt.format(mon=1, date=datetime.now())
114120
out, _ = capsys.readouterr()
115121
assert out.endswith(filename + "\n")
@@ -119,15 +125,15 @@ def test_entry_point(capsys):
119125
coordinates = "2,12,40,67"
120126
filename = "sct-2x12_40x67.png"
121127
for opt in ("-c", "--coordinates"):
122-
main([opt, coordinates])
128+
main(opt, coordinates)
123129
out, _ = capsys.readouterr()
124130
assert out.endswith(filename + "\n")
125131
assert os.path.isfile(filename)
126132
os.remove(filename)
127133

128134
coordinates = "2,12,40"
129135
for opt in ("-c", "--coordinates"):
130-
main([opt, coordinates])
136+
main(opt, coordinates)
131137
out, _ = capsys.readouterr()
132138
assert out == "Coordinates syntax: top, left, width, height\n"
133139

0 commit comments

Comments
 (0)